diff --git a/nextstrain/cli/runner/__init__.py b/nextstrain/cli/runner/__init__.py index f9fffcc2..0aaefd0e 100644 --- a/nextstrain/cli/runner/__init__.py +++ b/nextstrain/cli/runner/__init__.py @@ -1,7 +1,8 @@ import argparse -import builtins from argparse import ArgumentParser from typing import cast, List, Union, TYPE_CHECKING +# TODO: Use typing.TypeAlias once Python 3.10 is the minimum supported version. +from typing_extensions import TypeAlias from . import ( docker as __docker, conda as __conda, @@ -12,7 +13,7 @@ from .. import config, env, hostenv from ..argparse import DirectoryPath, SKIP_AUTO_DEFAULT_IN_HELP from ..errors import UserError -from ..types import Env, Options, RunnerModule +from ..types import EllipsisType, Env, Options, RunnerModule from ..util import prose_list, runner_name, runner_module, runner_help, warn from ..volume import NamedVolume @@ -70,7 +71,7 @@ % (configured_runner, runner_name(default_runner))) -RunnerExec = List[Union[str, 'builtins.ellipsis']] +RunnerExec: TypeAlias = List[Union[str, EllipsisType]] def register_runners(parser: ArgumentParser, diff --git a/nextstrain/cli/types.py b/nextstrain/cli/types.py index c4982675..a6df8229 100644 --- a/nextstrain/cli/types.py +++ b/nextstrain/cli/types.py @@ -4,13 +4,21 @@ import argparse import builtins +import sys import urllib.parse from pathlib import Path from typing import Any, Iterable, List, Mapping, Optional, Tuple, Union # TODO: Use typing.Protocol once Python 3.8 is the minimum supported version. -from typing_extensions import Protocol +# TODO: Use typing.TypeAlias once Python 3.10 is the minimum supported version. +from typing_extensions import Protocol, TypeAlias from .volume import NamedVolume +# Re-export EllipsisType so we can paper over its absence from older Pythons +if sys.version_info >= (3, 10): + from types import EllipsisType +else: + EllipsisType: TypeAlias = 'builtins.ellipsis' + """ An immutable mapping of (*name*, *value*) pairs representing a set of additional environment variables to overlay on the current environment (e.g. @@ -32,7 +40,7 @@ RunnerTestResults = List['RunnerTestResult'] RunnerTestResult = Tuple[str, 'RunnerTestResultStatus'] -RunnerTestResultStatus = Union[bool, None, 'builtins.ellipsis'] +RunnerTestResultStatus: TypeAlias = Union[bool, None, EllipsisType] RunnerUpdateStatus = Optional[bool]