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
Change untyped libraries from error to warning by default #10456
Change "found module but no type hints or library stubs" to a warning, not an error.
Change this:
lib.py:22: error: Skipping analyzing 'regex': found module but no type hints or library stubs
lib.py:136: error: Incompatible types in assignment (expression has type "float", variable has type "int")
persist.py:203: error: Skipping analyzing 'discord': found module but no type hints or library stubs
Found 2 errors in 2 files (checked 1 source file)
Into this:
lib.py:22: warning: Skipping analyzing 'regex': found module but no type hints or library stubs
lib.py:136: error: Incompatible types in assignment (expression has type "float", variable has type "int")
persist.py:203: warning: Skipping analyzing 'discord': found module but no type hints or library stubs
Found 1 error in 1 files (checked 1 source file)
Pitch
The vast majority of Python libraries lack type hints. Outside a group of highly skilled Pythonistas, few use type hints, partly because libraries don't use it. Showing that libraries fail to use type hints as an error dissuades new users from using mypy and hurts mypy adoption. Even without 3rd party type hints, type hinting a library internally can still be quite useful.
It also makes it harder to distinguish from actual typecheck errors.
Evidence
A lack of typing is the #1 most cited reason people avoid Python for large, "scalable" projects, and prefer Java, Go, or another statically typed language. On multiple occasions I have rebutted them by saying mypy exists and works well. Most of the time, the response is that most Python libraries do not support mypy. However, mypy can help people write Python in larger codebases without needing library type stubs.
This feature should be very useful.
By now, I had to set ignore_missing_imports=True.
Or use "grep -v 'found module but no type hints or library stubs'" to check bad import of my own code.
Activity
Bryant-Yang commentedon May 13, 2021
This feature should be very useful.
By now, I had to set ignore_missing_imports=True.
Or use "grep -v 'found module but no type hints or library stubs'" to check bad import of my own code.
[-]Change untyped libraries from error to warning[/-][+]Change untyped libraries from error to warning by default[/+]hauntsaninja commentedon Aug 13, 2023
I added support for this in #14740, use
--disable-error-code=import-untyped