-
-
Notifications
You must be signed in to change notification settings - Fork 296
Promoted getattr()
from FunctionDef to Lambda
#1472
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
Promoted getattr()
from FunctionDef to Lambda
#1472
Conversation
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.
Just adding some typing while we're at it 😄
Nice that that test suddenly works 👍
Edit: Btw, not sure if you have done this, but we might want to do a quick search in the open issues on pylint
and astroid
to see if that inference change for lambda's does not fix anything else .
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
for more information, see https://pre-commit.ci
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.
We could consider this a bug fix and test @Pierre-Sassoulas's new release process 😄 Considering the fact that this is breaking in the pylint
primer and we're handling the bug (and we're inferring more than we previously did), there is an argument to be made to do so. I'll leave that to the others though.
We would only need to change the position of the changelog entry.
Thanks @jacobtylerwalls 👍
Makes sense. But to be clear, it's not urgent -- nothing is blocking pylint -- we were just exploring whether we could remove an except case in pylint while working on pylint-dev/pylint#5544. However, at this point, any changes would be better off in a new PR with pylint regression tests. |
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.
LGTM. Let's put this in 2.11.1 changelog :)
9ba007b
to
90d5606
Compare
Steps
Description
Type of Changes
Related Issue
Lambdas can have special attributes, such as
__code__
, or even arbitrary attributes. Attempting to usegetattr
on thescoped_nodes.Lambda
instance, though, raisedAttributeError
.Now, it won't: the PR promotes
getattr()
fromFunctionDef
to its parent,Lambda
.Discovered by pylint's primer tests during an attempt to remove an
except: AttributeError
from pylint'sTypeChecker
, discussed here.