Skip to content

Commit b174a80

Browse files
committed
Python < 3.10 compatibility
1 parent ba42a8b commit b174a80

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/django_idom/hooks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Callable[..., Callable[..., Awaitable[Any]]],
1818
_database_sync_to_async,
1919
)
20-
WebsocketContext: Context[IdomWebsocket | None] = create_context(None)
20+
WebsocketContext: Context[Union[IdomWebsocket, None]] = create_context(None)
2121
_REFETCH_CALLBACKS: DefaultDict[
2222
Callable[..., Any], set[Callable[[], None]]
2323
] = DefaultDict(set)
@@ -45,10 +45,10 @@ def use_websocket() -> IdomWebsocket:
4545

4646

4747
def use_query(
48-
query: Callable[_Params, _Result | None],
48+
query: Callable[_Params, Union[_Result, None]],
4949
*args: _Params.args,
5050
**kwargs: _Params.kwargs,
51-
) -> Query[_Result | None]:
51+
) -> Query[Union[_Result, None]]:
5252
query_ref = use_ref(query)
5353
if query_ref.current is not query:
5454
raise ValueError(f"Query function changed from {query_ref.current} to {query}.")
@@ -96,8 +96,8 @@ def execute_query() -> None:
9696

9797

9898
def use_mutation(
99-
mutate: Callable[_Params, bool | None],
100-
refetch: Callable[..., Any] | Sequence[Callable[..., Any]],
99+
mutate: Callable[_Params, Union[bool, None]],
100+
refetch: Union[Callable[..., Any], Sequence[Callable[..., Any]]],
101101
) -> Mutation[_Params]:
102102
loading, set_loading = use_state(False)
103103
error, set_error = use_state(cast(Union[Exception, None], None))

src/django_idom/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Query(Generic[_Data]):
2929

3030
data: _Data
3131
loading: bool
32-
error: Exception | None
32+
error: Union[Exception, None]
3333
refetch: Callable[[], None]
3434

3535

@@ -39,5 +39,5 @@ class Mutation(Generic[_Params]):
3939

4040
execute: Callable[_Params, None]
4141
loading: bool
42-
error: Exception | None
42+
error: Union[Exception, None]
4343
reset: Callable[[], None]

0 commit comments

Comments
 (0)