We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
transitive_get
1 parent be97b4d commit 435bb4dCopy full SHA for 435bb4d
unification/utils.py
@@ -15,9 +15,16 @@ def transitive_get(key, d):
15
>>> transitive_get(1, d)
16
4
17
"""
18
- with suppress(TypeError):
19
- while key in d:
20
- key = d[key]
+ for _ in range(len(d)):
+ key = d[key]
+
21
+ with suppress(TypeError):
22
+ if key in d:
23
+ continue
24
+ break
25
+ else:
26
+ raise RecursionError('dict contains a loop')
27
28
return key
29
30
0 commit comments