-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
--check-untyped-defs-lite #7744
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
As of current master, mypy doesn't require annotations inside untyped functions (when you use Also we try to limit new mypy flags (instead, a meta-flag allow/disabling specific error codes is on our roadmap). |
I'm using master
It doesn't match my observation.
I confirmed that the errors are coming from untyped functions.
It doesn't seem as simple as globally filtering some error types. We only want the errors suppressed when they are originating from untyped functions. @ilevkivskyi Is there no merit to keeping this request open so that other people may consider it? |
Do you have a repro?
Let's first be sure the same can't be achieved using existing flags. |
I can also see that issue quite a lot. The most commen examples:
Or
|
My main use case is that I'd like to enforce quite strict typing rules for all my production code, but be not so strict in tests. Nevertheless, I want to typecheck the tests as far as possible with Or is there another way to disable all |
Uh oh!
There was an error while loading. Please reload this page.
This is a feature request for a mechanism allowing projects to benefit more from partial typing-- for example, typing of commonly used API's. (I envision it as a "lite" version of
--check-untyped-defs
.)use case
We have a project where there is a core API written by software engineers, while the bulk of the application uses those API's and is written by non-specialists (animators, researchers, etc.). (I don't think this scenario is uncommon.)
So far we only employ type hints sparingly, as a convenience for IDE autocompletion. For us, mypy is used merely to check for typos and syntax errors on the type annotations themselves.
We aren't motivated to add type hints to our common API's because mypy won't use that information unless the API usage sites themselves have type annotations. But it's not feasible for the non-specialist application authors to write and maintain such annotations.
So I would like to see mypy offer a way to use info from typed API's as much as possible (say to the extent of type inference available at the usage sites), without requiring annotations at the usage sites.
proposal
Add an option
--check-untyped-defs-lite
which will:--check-untyped-defs
, enable type checking on code which does not have type annotationsSo unlike
--check-untyped-defs
,--check-untyped-defs-lite
will never emit errors such as "Need type annotation for ..." and "Cannot determine type of ...".summary
This feature would allow an untold number of projects to benefit from using mypy even without having type annotations in their own code. It would strongly motivate more API's to be type annotated-- both 3rd party and a project's own common API.
The text was updated successfully, but these errors were encountered: