Method: pylint.checkers.utils.is_hashable
Calls: 474, Exceptions: 13, Paths: 5Back
Path 1: 444 calls (0.94)
Const (432) Attribute (7) Name (3) Tuple (2)
True (444)
1def is_hashable(node: nodes.NodeNG) -> bool:
2 """Return whether any inferred value of `node` is hashable.
3
4 When finding ambiguity, return True.
5 """
6 # pylint: disable = too-many-try-statements
7 try:
8 for inferred in node.infer():
9 if inferred is astroid.Uninferable or isinstance(inferred, nodes.ClassDef):
10 return True
11 if not hasattr(inferred, "igetattr"):
12 return True
13 hash_fn = next(inferred.igetattr("__hash__"))
14 if hash_fn.parent is inferred:
15 return True
16 if getattr(hash_fn, "value", True) is not None:
17 return True
18 return False
19 except astroid.InferenceError:
20 return True
Path 2: 13 calls (0.03)
Starred (9) Name (2) Set (2)
True (13)
InferenceError (11) NameInferenceError (2)
1def is_hashable(node: nodes.NodeNG) -> bool:
2 """Return whether any inferred value of `node` is hashable.
3
4 When finding ambiguity, return True.
5 """
6 # pylint: disable = too-many-try-statements
7 try:
8 for inferred in node.infer():
9 if inferred is astroid.Uninferable or isinstance(inferred, nodes.ClassDef):
10 return True
11 if not hasattr(inferred, "igetattr"):
12 return True
13 hash_fn = next(inferred.igetattr("__hash__"))
14 if hash_fn.parent is inferred:
15 return True
16 if getattr(hash_fn, "value", True) is not None:
17 return True
18 return False
19 except astroid.InferenceError:
20 return True
Path 3: 9 calls (0.02)
List (5) Attribute (1) Dict (1) Call (1) Slice (1)
False (9)
1def is_hashable(node: nodes.NodeNG) -> bool:
2 """Return whether any inferred value of `node` is hashable.
3
4 When finding ambiguity, return True.
5 """
6 # pylint: disable = too-many-try-statements
7 try:
8 for inferred in node.infer():
9 if inferred is astroid.Uninferable or isinstance(inferred, nodes.ClassDef):
10 return True
11 if not hasattr(inferred, "igetattr"):
12 return True
13 hash_fn = next(inferred.igetattr("__hash__"))
14 if hash_fn.parent is inferred:
15 return True
16 if getattr(hash_fn, "value", True) is not None:
17 return True
18 return False
19 except astroid.InferenceError:
20 return True
Path 4: 7 calls (0.01)
Name (6) Attribute (1)
True (7)
1def is_hashable(node: nodes.NodeNG) -> bool:
2 """Return whether any inferred value of `node` is hashable.
3
4 When finding ambiguity, return True.
5 """
6 # pylint: disable = too-many-try-statements
7 try:
8 for inferred in node.infer():
9 if inferred is astroid.Uninferable or isinstance(inferred, nodes.ClassDef):
10 return True
11 if not hasattr(inferred, "igetattr"):
12 return True
13 hash_fn = next(inferred.igetattr("__hash__"))
14 if hash_fn.parent is inferred:
15 return True
16 if getattr(hash_fn, "value", True) is not None:
17 return True
18 return False
19 except astroid.InferenceError:
20 return True
Path 5: 1 calls (0.0)
Lambda (1)
True (1)
1def is_hashable(node: nodes.NodeNG) -> bool:
2 """Return whether any inferred value of `node` is hashable.
3
4 When finding ambiguity, return True.
5 """
6 # pylint: disable = too-many-try-statements
7 try:
8 for inferred in node.infer():
9 if inferred is astroid.Uninferable or isinstance(inferred, nodes.ClassDef):
10 return True
11 if not hasattr(inferred, "igetattr"):
12 return True
13 hash_fn = next(inferred.igetattr("__hash__"))
14 if hash_fn.parent is inferred:
15 return True
16 if getattr(hash_fn, "value", True) is not None:
17 return True
18 return False
19 except astroid.InferenceError:
20 return True