Skip to content

Commit

Permalink
Merge branch 'trs/ellipsis-type'
Browse files Browse the repository at this point in the history
  • Loading branch information
tsibley committed Aug 31, 2023
2 parents ec82fed + 5f3f65d commit 3c93e87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions nextstrain/cli/runner/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions nextstrain/cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]

Expand Down

0 comments on commit 3c93e87

Please sign in to comment.