t3rn0 / ast-comments

Extension to the built-in ast module. Finds comments in source code and adds them to the parsed tree.
MIT License
31 stars 10 forks source link

Fixed taking the correct interval and placing them into the correct position #20

Closed Marc-Goritschnig closed 1 year ago

Marc-Goritschnig commented 1 year ago

The problem was with taking the max of the intervals, which were tuples of (x, y) values. We have to take the biggest starting interval, therefore biggest x, and then the smallest ending interval, meaning y. An example which did not work before and which put all comments in the beginning of the code after unparse is performed is: ` if 1 == 1:

Test1

print('a') else:

Test2

print('b') print('b') ` image

Marc-Goritschnig commented 1 year ago

I reworked all your requested changes

Marc-Goritschnig commented 1 year ago

i have changed those few things and formatted the file with intellijs pycharm, sadly i have not make tools currently and i cannot execute the script

if it is still necessary after the formatting i have done i would do that on the next weekend

t3rn0 commented 1 year ago

Merged it. In the next commit I made a few minor formatting changes. Thank you for making this PR. I'll ship it to PyPi with version==1.1.1 this weekend