Use isinstance() instead of type() ==

This commit is contained in:
Adam Goldsmith 2023-03-12 12:41:33 -04:00
parent fa4d07b628
commit ae80647870

View File

@ -59,11 +59,11 @@ def normalize_value(value):
return rounded return rounded
def recursively_normalize_values(d): def recursively_normalize_values(d):
if type(d) == dict: if isinstance(d, dict):
return {key: recursively_normalize_values(value) for key, value in d.items()} return {key: recursively_normalize_values(value) for key, value in d.items()}
elif type(d) == list: elif isinstance(d, list):
return [recursively_normalize_values(value) for value in d] return [recursively_normalize_values(value) for value in d]
elif type(d) == float: elif isinstance(d, float):
return normalize_value(d) return normalize_value(d)
else: else:
return d return d