You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately it seems I won't be able to fix it. There's a quirk in the Python tokenizer that makes it that any comment starting with # type is considered to be a type comment: python/typed_ast#62
The only option to make ast.parse to work with this is to disable parsing with type comments which obviously is not an options. At this point I think there are two options:
Start reporting the line on which the syntax error was found. That would mean reworking the com2ann function so it reports the errors itself. It would mean refactoring of majority of the tests.
Since we know on which line the syntax error was found, we can look if it's caused by a misplaced type comment. If it is, we can replace it with something else that would not trigger the error and try again. This would fix only one type of error and I was hoping to fix all the false syntax errors at once.
When a function in source file contains both type annotation comment and docstring, but in wrong order, com2ann fails with
SyntaxError
.Expected behaviour:
How to reproduce:
Create file test.py:
Call com2ann:
com2ann test.py
Output:
The text was updated successfully, but these errors were encountered: