|
1 | 1 | import dataclasses |
| 2 | +from collections.abc import Callable |
2 | 3 | from contextlib import ContextDecorator |
3 | 4 | from contextvars import ContextVar |
4 | 5 | from copy import deepcopy |
5 | | -from typing import Callable, Optional, Union |
6 | 6 |
|
7 | 7 | from taskbadger.internal import AuthenticatedClient |
8 | 8 | from taskbadger.systems import System |
9 | 9 |
|
10 | 10 | _local = ContextVar("taskbadger_client") |
11 | 11 |
|
12 | 12 |
|
13 | | -Callback = Union[str, Callable[[dict], Optional[dict]]] |
| 13 | +Callback = str | Callable[[dict], dict | None] |
14 | 14 |
|
15 | 15 |
|
16 | 16 | @dataclasses.dataclass |
@@ -47,7 +47,7 @@ class Session(ContextDecorator): |
47 | 47 | def __init__(self): |
48 | 48 | self._session = None |
49 | 49 |
|
50 | | - def __enter__(self) -> Union[AuthenticatedClient, None]: |
| 50 | + def __enter__(self) -> AuthenticatedClient | None: |
51 | 51 | if Badger.is_configured(): |
52 | 52 | self._session = Badger.current.session() |
53 | 53 | return self._session.__enter__() |
@@ -144,7 +144,7 @@ def client(self) -> AuthenticatedClient: |
144 | 144 | def scope(self) -> Scope: |
145 | 145 | return self._scope |
146 | 146 |
|
147 | | - def call_before_create(self, task: dict) -> Optional[dict]: |
| 147 | + def call_before_create(self, task: dict) -> dict | None: |
148 | 148 | if self.settings and self.settings.before_create: |
149 | 149 | return self.settings.before_create(task) |
150 | 150 | return task |
|
0 commit comments