Skip to content

Commit

Permalink
MAINT: simplify typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi committed Sep 6, 2023
1 parent d838772 commit 71f5926
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = {
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit 71f5926

Please sign in to comment.