-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Infer function parameter types using annotations #2216
Infer function parameter types using annotations #2216
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2216 +/- ##
==========================================
+ Coverage 92.71% 92.75% +0.03%
==========================================
Files 94 94
Lines 10837 10847 +10
==========================================
+ Hits 10048 10061 +13
+ Misses 789 786 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
The issue with this approach is that we have no way of knowing that the annotations are correct. Personally I wouldn't like I'm wondering what other maintainers thinks of this. |
I support this. If we could assume hinted return types were correct, I would think we could save a lot of time on inferencing, assuming we could skip manual inferencing.
I understand that |
We need to be careful here, using inference and not trusting annotations is the differentiating factor that makes pylint find issues that other tools don't in partially typed code base. On the other hand it would be nice to be able to detect that we're in a fully typed code base where we should trust the typing. This is not going to be trivial, unless we ask users to tell us via options. It seems possible to take typing in builtin into account without any drawbacks and without detecting anything or adding an option. (Because we know that typing are truthful and reliable in builtin) |
Type of Changes
Description
Fixes pylint-dev/pylint#4813
Fixes pylint-dev/pylint#8781
Type annotations are not currently used for inferencing, which means that, for example, functions with parameter typed as a
logging.Logger
would not receive relevant pylint warnings such aslogging-fstring-interpolation
.To make use of these type annotations, we now modify
infer_assign
to add yield additionalInstance
s if anAssignName
is being processed whoseparent
is anArguments
with annotations for theAssignName
.cc: @Pierre-Sassoulas