Skip to content

Commit

Permalink
Merge a2450c6 into 63738bf
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Sep 11, 2022
2 parents 63738bf + a2450c6 commit 14744e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/7453.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a crash in the ``unhashable-member`` checker when using a ``lambda`` as a dict key.

Closes #7453
2 changes: 2 additions & 0 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
return True
hash_fn = next(inferred.igetattr("__hash__"))
if hash_fn.parent is inferred:
return True
Expand Down
1 change: 1 addition & 0 deletions tests/functional/u/unhashable_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ class Unhashable:
{[1, 2, 3]} # [unhashable-member]
{"tomato": "tomahto"}
{dict: {}}
{lambda x: x: "tomato"} # pylint: disable=unnecessary-lambda

0 comments on commit 14744e2

Please sign in to comment.