resolve conflict and add type hints for it

This commit is contained in:
TonyCrane
2022-02-16 11:46:55 +08:00
10 changed files with 366 additions and 355 deletions

View File

@ -155,3 +155,14 @@ def remove_nones(sequence: Iterable) -> list:
def concatenate_lists(*list_of_lists):
return [item for l in list_of_lists for item in l]
def hash_obj(obj: object) -> int:
if isinstance(obj, dict):
new_obj = {k: hash_obj(v) for k, v in obj.items()}
return hash(tuple(frozenset(sorted(new_obj.items()))))
if isinstance(obj, (set, tuple, list)):
return hash(tuple(hash_obj(e) for e in obj))
return hash(obj)