Skip to content

Commit b3f9a2f

Browse files
committed
fix: replace | union syntax with Union for Python 3.9 compatibility
Replace runtime | operator with Union from typing to support Python 3.9-3.13: - graphql/constants.py: VARIABLE_TYPE_MAPPING tuples - diff.py: GraphQL query variables dict The | operator for types only works at runtime in Python 3.10+.
1 parent 0b48ff7 commit b3f9a2f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

infrahub_sdk/diff.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import (
55
Any,
6+
Union,
67
)
78

89
from typing_extensions import NotRequired, TypedDict
@@ -199,8 +200,8 @@ def get_diff_tree_query() -> Query:
199200
},
200201
variables={
201202
"branch_name": str,
202-
"name": str | None,
203-
"from_time": datetime | None,
204-
"to_time": datetime | None,
203+
"name": Union[str, None],
204+
"from_time": Union[datetime, None],
205+
"to_time": Union[datetime, None],
205206
},
206207
)

infrahub_sdk/graphql/constants.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from datetime import datetime
2+
from typing import Union
23

34
VARIABLE_TYPE_MAPPING = (
45
(str, "String!"),
5-
(str | None, "String"),
6+
(Union[str, None], "String"),
67
(int, "Int!"),
7-
(int | None, "Int"),
8+
(Union[int, None], "Int"),
89
(float, "Float!"),
9-
(float | None, "Float"),
10+
(Union[float, None], "Float"),
1011
(bool, "Boolean!"),
11-
(bool | None, "Boolean"),
12+
(Union[bool, None], "Boolean"),
1213
(datetime, "DateTime!"),
13-
(datetime | None, "DateTime"),
14+
(Union[datetime, None], "DateTime"),
1415
)

0 commit comments

Comments
 (0)