-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix unhashable-member
crash when lambda
used as a dict key
#7454
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 unhashable-member
crash when lambda
used as a dict key
#7454
Conversation
unhashable-member
crash when lambda
used as a dict keyunhashable-member
crash when lambda
used as a dict key
Pull Request Test Coverage Report for Build 3033283713
π - Coveralls |
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.
Thank you for the quick fix !
pylint/checkers/utils.py
Outdated
@@ -38,6 +38,15 @@ | |||
nodes.DictComp, | |||
nodes.GeneratorExp, | |||
) | |||
WITH_IGETATTR = ( |
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.
Isn't it possible to use has_attr("igetattr"
and have something generic instead ?
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.
Sure, I just figured this was more explicit.
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.
Old python is more duck-type-y, and modern python seems to be more explicit. π€·π»ββοΈ
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.
this was more explicit.
Sure but if another class with igetattr
appear we'd need to remember to add it there, which is unlikely to be caught in review, right ?
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.
That makes sense, will change.
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit a2450c6 |
@@ -1950,6 +1950,8 @@ def is_hashable(node: nodes.NodeNG) -> bool: | |||
for inferred in node.infer(): | |||
if inferred is astroid.Uninferable: | |||
return True | |||
if not hasattr(inferred, "igetattr"): |
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.
mypy
will complain about this when we add py.typed
to astroid
, but that is a problem to fix then I think.
Type of Changes
Description
Closes #7453