Skip to content

Commit 87b6690

Browse files
committed
dev: Use types.EllipsisType instead of 'builtins.ellipsis' when we can
The former is preferable as its not a private/internal type¹, but it's only available on on Python ≥3.10.² ¹ <python/cpython#85976> ² <https://docs.python.org/3/library/types.html#types.EllipsisType>
1 parent 2e67031 commit 87b6690

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

nextstrain/cli/runner/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .. import config, env, hostenv
1515
from ..argparse import DirectoryPath, SKIP_AUTO_DEFAULT_IN_HELP
1616
from ..errors import UserError
17-
from ..types import Env, Options, RunnerModule
17+
from ..types import EllipsisType, Env, Options, RunnerModule
1818
from ..util import prose_list, runner_name, runner_module, runner_help, warn
1919
from ..volume import NamedVolume
2020

@@ -72,7 +72,7 @@
7272
% (configured_runner, runner_name(default_runner)))
7373

7474

75-
RunnerExec: TypeAlias = List[Union[str, 'builtins.ellipsis']]
75+
RunnerExec: TypeAlias = List[Union[str, EllipsisType]]
7676

7777

7878
def register_runners(parser: ArgumentParser,

nextstrain/cli/types.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import argparse
66
import builtins
7+
import sys
78
import urllib.parse
89
from pathlib import Path
910
from typing import Any, Iterable, List, Mapping, Optional, Tuple, Union
@@ -12,6 +13,12 @@
1213
from typing_extensions import Protocol, TypeAlias
1314
from .volume import NamedVolume
1415

16+
# Re-export EllipsisType so we can paper over its absence from older Pythons
17+
if sys.version_info >= (3, 10):
18+
from types import EllipsisType
19+
else:
20+
EllipsisType: TypeAlias = 'builtins.ellipsis'
21+
1522
"""
1623
An immutable mapping of (*name*, *value*) pairs representing a set of
1724
additional environment variables to overlay on the current environment (e.g.
@@ -33,7 +40,7 @@
3340

3441
RunnerTestResults = List['RunnerTestResult']
3542
RunnerTestResult = Tuple[str, 'RunnerTestResultStatus']
36-
RunnerTestResultStatus: TypeAlias = Union[bool, None, 'builtins.ellipsis']
43+
RunnerTestResultStatus: TypeAlias = Union[bool, None, EllipsisType]
3744

3845
RunnerUpdateStatus = Optional[bool]
3946

0 commit comments

Comments
 (0)