File tree 3 files changed +10
-1
lines changed
3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change
1
+ Fix false positive for ``unhashable-member`` when subclassing ``dict`` and using the subclass as a dictionary key.
2
+
3
+ Closes #7501
Original file line number Diff line number Diff line change @@ -1955,7 +1955,7 @@ def is_hashable(node: nodes.NodeNG) -> bool:
1955
1955
"""
1956
1956
try :
1957
1957
for inferred in node .infer ():
1958
- if inferred is astroid .Uninferable :
1958
+ if inferred is astroid .Uninferable or isinstance ( inferred , nodes . ClassDef ) :
1959
1959
return True
1960
1960
if not hasattr (inferred , "igetattr" ):
1961
1961
return True
Original file line number Diff line number Diff line change @@ -22,3 +22,9 @@ class Unhashable:
22
22
{"tomato" : "tomahto" }
23
23
{dict : {}}
24
24
{lambda x : x : "tomato" } # pylint: disable=unnecessary-lambda
25
+
26
+
27
+ class FromDict (dict ):
28
+ ...
29
+
30
+ {FromDict : 1 }
You can’t perform that action at this time.
0 commit comments