-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Maybe suppress all/most errors in unannotated functions #1370
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
@ahaven you expressed interest in this idea earlier -- any messages that you find particularly noisy/annoting? |
Here's the big ones:
The error it gives is because this constructor isn't stubbed (see #984), but it gives the error even inside of unannotated functions.
which gives "error: Name 'reconstruct' already defined". I'd like to go through and clean these up at some point, but I don't like that mypy's erroring on them right now because they're unannotated. |
The first error is from type checking. Mypy actually checks that functions and type objects are called with compatible argument count and keyword argument names, and if a stub is incorrect it can complain within dynamically typed functions. This could be easily fixed by giving all functions the type The latter is probably because some conditional definitions aren't supported within functions :-/ It shouldn't be very hard to get this right, just cumbersome. |
For 1) I'd be happier with a correct stub for |
But can a correct stub be made to work without changes to mypy itself? If
so, we should definitely do that. But I don't know whether it's possible.
|
We can't define a correct stub for
The problem with annotating We could decide that an overload variant with
We could use union types for a more general signature for the Alternatively, we could use the same
The constraint based approach could be generalized for other kinds of special signatures, but it would likely be harder to explain to users. A plugin system could use declarative constraints internally, though. |
My inclination would be to prioritize people's ability to adopt I think there is a use case for applying the checks like compatible On Thu, Apr 14, 2016 at 5:09 AM, Jukka Lehtosalo notifications@github.com
|
I'm leaning towards agreeing with @gnprice. |
Just to be clear, the action items appear to be (a) fix the mixed dict signature, (b) suppress errors from semantic analysis in unannotated functions. Right? |
Yeah, and if (a) isn't good enough (e.g., if there are many functions that generate false positives), we can also suppress errors from type checking in unannotated functions. |
We've started suppressing all errors from semantic analysis in unannotated functions. Given the title of this issue I am closing it. (Though it seems an odd duplicate if #1415.) |
The semantic analysis can generate quite a few errors when run on a large unannotated code base.
When such errors refer to the body of an unannotated function, this violates people's expectations based on a simplified definition of gradual typing ("mypy only checks the body of a function when it's annotated").
This noise makes it less feasible to approach such a code base piecemeal (annotating one function/class/file at a time, then hunting down the errors).
OTOH there are perhaps some errors from semantic analysis that are useful.
We should do some kind of survey and either silence some of the noisiest errors from semantic analysis or (almost) all of them, depending on the outcome.
The text was updated successfully, but these errors were encountered: