Promoted getattr() from FunctionDef to Lambda#1472
Conversation
There was a problem hiding this comment.
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.
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. |
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
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 usegetattron thescoped_nodes.Lambdainstance, though, raisedAttributeError.Now, it won't: the PR promotes
getattr()fromFunctionDefto its parent,Lambda.Discovered by pylint's primer tests during an attempt to remove an
except: AttributeErrorfrom pylint'sTypeChecker, discussed here.