Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThere should be a way to tell the type checker not to check (specific) 3rd party packages #53
Comments
|
Sounds reasonable. I added a mypy issue for this: python/mypy#562 I see three different categories of modules that don't import Mypy currently complains about code like this if there is no annotation, even for dynamically typed modules, since module top levels are implicitly statically typed by default:
I'd like to change this so that mypy could process at least many existing modules and still support some level of type checking for code that imports those modules (e.g., checking that function argument counts are compatible). Maybe category (1) modules should default to |
|
Moved to README.rst. |
Suppose I am writing an app using type hints but I am importing a 3rd party package that uses annotations for some other purpose. And suppose the author of that package isn't motivated to add
# type: OFFcomments to the top of every module, and I don't want to have to patch the package every time I install or upgrade it. Then there should be a way to tell the type checker not to check that package, or at least to ignore all annotations in it.This can probably be a configuration option for the type checker, so perhaps this should be a mypy issue, not a PEP issue, but I think this would be a useful thing to mention in the PEP so people don't worry too much about 3rd party code using annotations for other purposes.
(An alternative would be not to type-check modules that don't import [from] typing, but I think that's limiting, because lots of code never needs any of the facilities defined there, it just wants to use annotations that use built-in types or locally-defined classes.)