diff --git a/src/wakepy/core/mode.py b/src/wakepy/core/mode.py index b269bee8..f4b75535 100644 --- a/src/wakepy/core/mode.py +++ b/src/wakepy/core/mode.py @@ -26,15 +26,22 @@ from .registry import get_method, get_methods_for_mode if typing.TYPE_CHECKING: + import sys from types import TracebackType - from typing import Callable, List, Literal, Optional, Tuple, Type + from typing import Callable, List, Optional, Tuple, Type, Union from .constants import Collection, ModeName, StrCollection from .dbus import DBusAdapter, DBusAdapterTypeSeq from .method import Method, MethodCls from .prioritization import MethodsPriorityOrder - OnFail = Literal["error", "warn", "pass"] | Callable[[ActivationResult], None] + + if sys.version_info < (3, 8): # pragma: no-cover-if-py-gte-38 + from typing_extensions import Literal + else: # pragma: no-cover-if-py-lt-38 + from typing import Literal + + OnFail = Union[Literal["error", "warn", "pass"], Callable[[ActivationResult], None]] MethodClsCollection = Collection[MethodCls] diff --git a/src/wakepy/core/prioritization.py b/src/wakepy/core/prioritization.py index f58eedc1..ce9030aa 100644 --- a/src/wakepy/core/prioritization.py +++ b/src/wakepy/core/prioritization.py @@ -13,26 +13,14 @@ import typing from typing import List, Sequence, Set, Union -from .activationresult import ActivationResult from .constants import WAKEPY_FAKE_SUCCESS from .platform import CURRENT_PLATFORM if typing.TYPE_CHECKING: - import sys - from typing import Callable, List, Optional, Tuple, Union + from typing import List, Optional, Tuple, Union - from .constants import Collection from .method import MethodCls - if sys.version_info < (3, 8): # pragma: no-cover-if-py-gte-38 - from typing_extensions import Literal - else: # pragma: no-cover-if-py-lt-38 - from typing import Literal - - OnFail = Union[Literal["error", "warn", "pass"], Callable[[ActivationResult], None]] - - MethodClsCollection = Collection[MethodCls] - """The strings in MethodsPriorityOrder are names of wakepy.Methods or the asterisk ('*').""" MethodsPriorityOrder = Sequence[Union[str, Set[str]]]