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
ignore stubs but get an error if module is missing #9115
Hi I am using mypy:0.782 with python3.5 and I want to use it to check if my imports are valid
for example I would like to raise an error for import PIL # package pillow if its not installed on the build machine.
but mypy complains when installed:
file.py:10: error: Skipping analyzing 'PIL': found module but no type hints or library stubs
file.py:10: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
when not installed:
file.py.py:10: error: Cannot find implementation or library stub for module named 'PIL'
file.py:10: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
when adding #type: ignore all errors are ignored for this package, but I would like to surpress only the missing library stubs but
raise an error if the module is not found at all. I can't find a flag for that purpose.
Error codes are meant for things like this except that the error code is [import] in both cases
Maybe one of the error codes should be module-not-found and the other should be stubs-not-found, or something like that? then you could do # type: ignore[stubs-not-found]
Activity
Akuli commentedon Aug 18, 2020
Error codes are meant for things like this except that the error code is
[import]in both casesMaybe one of the error codes should be
module-not-foundand the other should bestubs-not-found, or something like that? then you could do# type: ignore[stubs-not-found]hauntsaninja commentedon Aug 13, 2023
I fixed this in #14740, use
--disable-error-code=import-untyped