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
{{ message }}
Repository navigation
Type ignore comment has no effect after argument type comment #5967
Note the type_comment='x # type: ignore'.
We generally ignore comments after the first type comment, but it should be easy to make an exception for #\s+type:\s+ignore and add that line to the list of lines to ignore.
I believe I have hacked together a general implementation in fastparse. I just do a regex search for a # type: ignore when parsing the type comment and keep track of these additional type ignores in the Ast converter class, then add them to the set of ignores when visiting the Module node.
Though this likely should be implemented in typed_ast itself...
Edit: looking over the typed_ast code, it does not seem simple to implement this, maybe putting this in fastparse is ok?
Activity
emmatyping commentedon Nov 28, 2018
For your first example, here is the AST as parsed by typed_ast:
Note the
type_comment='x # type: ignore'.We generally ignore comments after the first type comment, but it should be easy to make an exception for
#\s+type:\s+ignoreand add that line to the list of lines to ignore.JukkaL commentedon Nov 28, 2018
This happens also with variable type comments:
JukkaL commentedon Nov 28, 2018
Increasing priority since it's not at all obvious how to work this around in general.
emmatyping commentedon Nov 28, 2018
I believe I have hacked together a general implementation in fastparse. I just do a regex search for a
# type: ignorewhen parsing the type comment and keep track of these additional type ignores in the Ast converter class, then add them to the set of ignores when visiting theModulenode.Though this likely should be implemented in typed_ast itself...Edit: looking over the typed_ast code, it does not seem simple to implement this, maybe putting this in fastparse is ok?
Allow type ignores after type comments
Allow type ignores after type comments (#6591)