Fix deep_get not returning the correct on success

I forgot to actually return the given data if we manage to index to the
requested depth
This commit is contained in:
A_D authored and Athanasius committed 2020-07-26 23:08:47 +01:00
1 parent 2403ed1d2f
commit b6482878f0
1 file changed
+7 -5
+7 -5
View File
@@ -49,16 +49,18 @@ def versioncmp(versionstring):
def deep_get(target: dict, *args: str, default=None) -> Any:
if not hasattr(target, 'get'):
raise ValueError("Cannot call get on {} ({})".format(target, type(target)))
current = target
for arg in args:
res = current.get(arg)
if res is not None:
current = res
if res is None:
return default
else:
break
current = res
return default
return current
def main():