-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix E1102 / not-callable
false positive for property that returns a lambda function conditionally
#6068
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 E1102 / not-callable
false positive for property that returns a lambda function conditionally
#6068
Conversation
Pull Request Test Coverage Report for Build 2081161263
💛 - Coveralls |
for more information, see https://pre-commit.ci
zamn :^) |
not-callable
false positive for property that return a lambda function conditionnally
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.
nice! one suggestion to loosen this even more.
Co-authored-by: Jacob Walls <[email protected]>
@jacobtylerwalls loosening it to decline any instance of Here's an example from the test case: class PropertyTest(object):
""" class """
def __init__(self):
self.attr = 4
@property
def test(self):
""" Get the attribute """
return self.attr
@test.setter
def test(self, value):
""" Set the attribute """
self.attr = value
PROP = PropertyTest()
PROP.test(40) # [not-callable] This is the result of
Since we inferred one |
Thanks for looking into it. Darn. I still think long-term we could consider making that change, though. There's no restriction on what you can set with the property. You can set something that's callable, and then |
@tushar-deepsource Coming into this pretty late but I was taking a look at stale PRs and found #5593. Could you quickly check if this solves that issue? |
@DanielNoord This change only affects properties, so no it doesn't solve that issue. |
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.
Only needs a changelog entry!
Didn't see this was only for properties
. But that makes sense :)
@DanielNoord hopefully this is correct? |
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.
Almost 😄
But thanks @tushar-deepsource! Wonderful fix!
Co-authored-by: Daniël van Noord <[email protected]>
not-callable
false positive for property that return a lambda function conditionnallynot-callable
false positive for property that returns a lambda function conditionally
Are we moving the changelog entry to 2.13.5? |
… a lambda function conditionally (#6068) Co-authored-by: Jacob Walls <[email protected]> Co-authored-by: Daniël van Noord <[email protected]> Co-authored-by: Pierre Sassoulas <[email protected]>
Type of Changes
Description
Update E1102 to only be raised when no inferred value is callable.
Resolves #5931