Skip to content

Commit

Permalink
fix compilation error on py39
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbull committed Nov 20, 2024
1 parent 84c50f6 commit f787404
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/aiida/storage/sqlite_zip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def sqlite_case_sensitive_like(dbapi_connection, _):
cursor.close()


def _contains(lhs: dict | list, rhs: dict | list):
def _contains(lhs: Union[dict, list], rhs: Union[dict, list]):
if isinstance(lhs, dict) and isinstance(rhs, dict):
for key in rhs:
if key not in lhs or not _contains(lhs[key], rhs[key]):
Expand All @@ -63,13 +63,15 @@ def _contains(lhs: dict | list, rhs: dict | list):
return lhs == rhs


def _json_contains(json1_str: AnyStr, json2_str: AnyStr):
def _json_contains(lhs: Union[str, bytes, bytearray, dict, list], rhs: Union[str, bytes, bytearray, dict, list]):
try:
json1 = json.loads(json1_str)
json2 = json.loads(json2_str)
if isinstance(lhs, (str, bytes, bytearray)):
lhs = json.loads(lhs)
if isinstance(rhs, (str, bytes, bytearray)):
rhs = json.loads(rhs)
except json.JSONDecodeError:
return 0
return int(_contains(json1, json2))
return int(_contains(lhs, rhs))


def register_json_contains(dbapi_connection, _):
Expand Down

0 comments on commit f787404

Please sign in to comment.