-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Type ignore comment has no effect after argument type comment #5967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For your first example, here is the AST as parsed by typed_ast:
Note the |
This happens also with variable type comments: x = 1 # type: str # type: ignore |
Increasing priority since it's not at all obvious how to work this around in general. |
I believe I have hacked together a general implementation in fastparse. I just do a regex search for a
|
This is a bit of a hack in fastparse, but allows for the following to pass typechecking: `x = 1 # type: str # type: ignore` Fixes python#5967
This is a hack in fastparse, but allows for the following to pass typechecking: `x = 1 # type: str # type: ignore` This also handles the edge case where there is a `# type: ignore` in a comment, which we don't want to pick up. See the tests for more examples. Fixes #5967
This program generates an error on the first line even though there is a
# type: ignore
comment:Similarly, this generates an error even though it shouldn't:
The text was updated successfully, but these errors were encountered: