-
-
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
fix false negative when isinstance
is provided too many or too few arguments
#9868
fix false negative when isinstance
is provided too many or too few arguments
#9868
Conversation
a78b197
to
9da13f0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
This comment has been minimized.
This comment has been minimized.
Nice! Could you add a check for < 2 args too, as in |
2a53891
to
4bffdbd
Compare
@nickdrozd I've noticed that there isn't a pylint warning for |
4bffdbd
to
a7f47ad
Compare
This comment has been minimized.
This comment has been minimized.
- add too-many-function-args call - include handling for too-few-function-args
a7f47ad
to
9682d47
Compare
a3f1c8d
to
3cc7e7f
Compare
This comment has been minimized.
This comment has been minimized.
For me the only thing that matters is that bad @jacobtylerwalls, any thoughts? |
The test looks pretty fixable; I'll get to that tonight. I've gotten the changelog error a number of times here. It looks like the test is not happy with seeing |
This comment has been minimized.
This comment has been minimized.
Don't worry about the _template.rst issue, not related to this MR :) |
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #9868 +/- ##
=======================================
Coverage 95.80% 95.80%
=======================================
Files 174 174
Lines 18939 18942 +3
=======================================
+ Hits 18144 18147 +3
Misses 795 795
|
This comment has been minimized.
This comment has been minimized.
isinstance
is provided too many argumentsisinstance
is provided too many or too few arguments
I see that I needed to run the |
Also, it would appear that the https://github.com/pylint-dev/pylint/actions/runs/10382711912/job/28746257136 However, https://github.com/pylint-dev/pylint/actions/runs/10382595367/job/28769681193 It would appear that they are looking at different cache keys, at least. |
Thanks, I'll look into it. Speaking of the primer, I noticed there are warnings newly emitted (expand the "Echo Warnings" step). |
But the warning just looks like #9138, which was supposed to have been solved, maybe there really is a bad cache key somewhere? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good, just some documentation nits and this should be g2g
This comment has been minimized.
This comment has been minimized.
Oh, and you can forget this -- the warnings are happening on main now, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful, thanks!
@jacobtylerwalls Thanks a lot for providing some great feedback! π |
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 2d6db8a |
Thanks for working on this @rogersheu! Looking forward to seeing this warning the next time I mess up some |
No probs, @nickdrozd , thanks for making this suggestion in the first place! Might be nice if this could someday be extended for other built-in functions π€ , but then again, maybe it'd be easier to expand on the |
@@ -0,0 +1 @@ | |||
isinstance("foo") # [too-few-function-args] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something minor for next time: in the pylint docs we tend to avoid "foo" and "bar" because junior programmers are often the target audience, and if they don't know the convention/backstory it has the potential to be distracting.
Also, "foo"
is a literal just like 1
-- I was suggesting to change it for the reason that if we introduce a check later like literal-isinstance
(in the spirit of using-constant-test
), then we'll have to adjust this example. But let's not change it now, I'm not sure it's worth fleshing out this example more.
Type of Changes
Description
In #9847, @nickdrozd pointed out that when the wrong number of arguments (specifically too many) are passed to
isinstance
, we see a false negative, where no pylint warning comes out despite the issue.Though it has been previously pointed out that built-in functions do not provide relevant argument information, i.e., expected number of arguments, we can for now rely on
isinstance
taking exactly two arguments to provide the user with atoo-many-arguments
warning.pylint/pylint/checkers/typecheck.py
Line 1455 in 466c671
A functional test has also been included to account for this case. The
isinstance
call makes aTypeError
, so that must be caught in order forpylint
to find thetoo-many-arguments
issue successfully.Closes #9847