-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Take type annotation into account when inference fails #4813
Comments
I'm not sure we should actually do this. How would we handle incorrectly typed functions/variables? We would need to run The biggest benefit of this would be that you can explicitly type stuff that |
(If we use typing I would do it only when inference failed and assume it's correct instead of re-implementing a type checker entirely) But I think control flow capability is indeed more important. The strength of pylint lie in it's inference, so it make sense to make the inference better before trying to use typing as crutches when inference fails. |
Indeed! Let's close this: we will likely never close this as it isn't within the current scope of the project and there are far too many things that are within that scope and haven't been fixed yet. Edit: @Pierre-Sassoulas I saw you mentioned this issue somewhere else. I guess you don't want to close? |
I see that as a really long term goal. But I think keeping the discussion open permit to point to it when an issue is opened and solvable only by using annotations so we can close the other issue without writting a novel. |
I was wondering why there was no version 4.0 and the milestones skipped from Version 3 to Version 5. Now I am wondering why the version 4.0 milestone was closed before version 3.0. |
It's a long term goal, putting it in the farther milestone is supposed to convey that, but we could also remove the milestone entirely. |
This is fine. I see that the milestone for 4.0 has been added back. |
Current problem
Right now pylint relies on its own inference engine, which ultimately is somewhat basic. This leads to quite a lot of false positives for deep inspections such as no-member, since what the entire inference is doing is just solving the variables into what values they might represent. In some cases it can properly infer the true value, in other cases we just infer a None or raise an inference error. This leads to quite a few false positives in which we cannot properly deduce the actual types due to the limited inference capabilities.
Desired solution
While mypy is a fully fledged type checker, in our case we only need some support of type inference for function signatures and assignment signatures as well, in which case we could assume the type passed from the type signature instead of relying on our inference. This could also mean better performance, as we won't have to walk the tree calling the inference to figure out the type. A similar project that works in the same vein is jedi which doesn't need to do full type analysis as mypy is doing.
Additional context
Taken from the comment from @PCManticore here
The text was updated successfully, but these errors were encountered: