-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Can't fully ignore file with syntax error generated from mypy-protobuf library #6897
Comments
Sometimes bug reports can read so negative, so let me just say huge thanks to contributors for making mypy available, love it to bits. |
Unfortunately the way .pyi files are parsed makes it hard to fix this, even if it is a bug. (I think it's probably undefined.) In the meantime, can you report the problem with the mypy-protobuf project? The .py generator for protobuf files must be able to generate code for this without syntax errors (presumably by renaming the variable somehow), and mypy-protobuf should follow its lead. |
Ignoring syntax errors would be hard to support in a useful way, since we'd have no AST to work with. I don't think there's anything straightforward we can do here (other than completely ignoring the file, which seems dangerous). |
Bug. I think. This may be intended behaviour, but in that case it's problematic. I think my question is related to, but not a duplicate of, #6155
Using https://github.com/dropbox/mypy-protobuf/ I generate Protobuf .pyi files. I don't want mypy to analyze these files because they are autogenerated, but mypy seems unable to fully exclude a file when it has syntax errors.
This is the exact error from mypy:
This is a snippet of
package/schemas/foo_pb2.pyi
file:Notice the
from = ...
, that's straight from the mypy-protobuf output but it's invalid Python. That doesn't appear to be a real problem in a .pyi file, but the problem is mypy can't seem to fully ignore checking this file.This is my
mypy.ini
:This file works, in so far that without the .pyi files errors are ignored in the remaining
pb2.py
files. But the above syntax error is not ignored. I assumeignore_errors
only ignores errors but not syntax errors? I went looking for anignore_syntax_errors = True
flag but that does not appear to exist.I'm using versions:
I'm running mypy using this command:
Here is a gist with the entire contents of the .proto file, the generated (and successfully excluded) .py file, and the problematic and unexcludable .pyi file:
https://gist.github.com/gaggle/8aef6102d314936c9eb33724194682b0
The text was updated successfully, but these errors were encountered: