diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index 93b2c37bc..541256f4c 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -54,6 +54,8 @@ from mesonpy._compat import Collection, Mapping, cached_property, read_binary +_MESON_ARGS_KEYS = ['dist', 'setup', 'compile', 'install'] + if typing.TYPE_CHECKING: # pragma: no cover from typing import Any, Callable, DefaultDict, List, Literal, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union @@ -62,20 +64,11 @@ P = ParamSpec('P') T = TypeVar('T') - -__version__ = '0.15.0.dev0' - - -# XXX: Once Python 3.8 is our minimum supported version, get rid of -# meson_args_keys and use typing.get_args(MesonArgsKeys) instead. - -# Keep both definitions in sync! -_MESON_ARGS_KEYS = ['dist', 'setup', 'compile', 'install'] -if typing.TYPE_CHECKING: MesonArgsKeys = Literal['dist', 'setup', 'compile', 'install'] MesonArgs = Mapping[MesonArgsKeys, List[str]] -else: - MesonArgs = dict + + +__version__ = '0.15.0.dev0' _COLORS = { @@ -940,7 +933,7 @@ def _project(config_settings: Optional[Dict[Any, Any]] = None) -> Iterator[Proje """Create the project given the given config settings.""" settings = _validate_config_settings(config_settings or {}) - meson_args = typing.cast(MesonArgs, {name: settings.get(f'{name}-args', []) for name in _MESON_ARGS_KEYS}) + meson_args = typing.cast('MesonArgs', {name: settings.get(f'{name}-args', []) for name in _MESON_ARGS_KEYS}) source_dir = os.path.curdir build_dir = settings.get('builddir') editable_verbose = bool(settings.get('editable-verbose'))