Skip to content

Commit d463b25

Browse files
dnicolodirgommers
authored andcommitted
MAINT: simplify typing
1 parent c95da87 commit d463b25

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

mesonpy/__init__.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import typing
3535
import warnings
3636

37-
from typing import Dict
38-
3937

4038
if sys.version_info < (3, 11):
4139
import tomli as tomllib
@@ -51,31 +49,24 @@
5149
import mesonpy._util
5250
import mesonpy._wheelfile
5351

54-
from mesonpy._compat import Collection, Mapping, cached_property, read_binary
52+
from mesonpy._compat import cached_property, read_binary
53+
5554

55+
_MESON_ARGS_KEYS = ['dist', 'setup', 'compile', 'install']
5656

5757
if typing.TYPE_CHECKING: # pragma: no cover
58-
from typing import Any, Callable, DefaultDict, List, Literal, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union
58+
from typing import Any, Callable, DefaultDict, Dict, List, Literal, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union
5959

60-
from mesonpy._compat import Iterator, ParamSpec, Path
60+
from mesonpy._compat import Collection, Iterator, Mapping, ParamSpec, Path
6161

6262
P = ParamSpec('P')
6363
T = TypeVar('T')
6464

65-
66-
__version__ = '0.15.0.dev0'
67-
68-
69-
# XXX: Once Python 3.8 is our minimum supported version, get rid of
70-
# meson_args_keys and use typing.get_args(MesonArgsKeys) instead.
71-
72-
# Keep both definitions in sync!
73-
_MESON_ARGS_KEYS = ['dist', 'setup', 'compile', 'install']
74-
if typing.TYPE_CHECKING:
7565
MesonArgsKeys = Literal['dist', 'setup', 'compile', 'install']
7666
MesonArgs = Mapping[MesonArgsKeys, List[str]]
77-
else:
78-
MesonArgs = dict
67+
68+
69+
__version__ = '0.15.0.dev0'
7970

8071

8172
_COLORS = {
@@ -952,7 +943,7 @@ def _project(config_settings: Optional[Dict[Any, Any]] = None) -> Iterator[Proje
952943
"""Create the project given the given config settings."""
953944

954945
settings = _validate_config_settings(config_settings or {})
955-
meson_args = typing.cast(MesonArgs, {name: settings.get(f'{name}-args', []) for name in _MESON_ARGS_KEYS})
946+
meson_args = typing.cast('MesonArgs', {name: settings.get(f'{name}-args', []) for name in _MESON_ARGS_KEYS})
956947
source_dir = os.path.curdir
957948
build_dir = settings.get('build-dir')
958949
editable_verbose = bool(settings.get('editable-verbose'))

0 commit comments

Comments
 (0)