diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-01 23:12:54 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-07 19:01:04 -0500 |
commit | 187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770 (patch) | |
tree | 5ed516e772e7edb4ab38c12feaf763fe030cf888 /mesonbuild/modules | |
parent | d072ebc9554e5661419d6d75285bfee24dca743f (diff) | |
download | meson-187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770.zip meson-187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770.tar.gz meson-187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770.tar.bz2 |
merge various TYPE_CHECKING blocks into one
A bunch of files have several T.TYPE_CHECKING blocks that each do some
things which could just as well be done once, with a single `if`
statement. Make them do so.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/python.py | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index f149ca1..486c63b 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -38,28 +38,52 @@ from ..mesonlib import MachineChoice from ..programs import ExternalProgram, NonExistingExternalProgram if T.TYPE_CHECKING: + from typing_extensions import TypedDict + from . import ModuleState from ..build import SharedModule, Data from ..dependencies import ExternalDependency, Dependency from ..dependencies.factory import DependencyGenerator from ..environment import Environment from ..interpreter import Interpreter + from ..interpreter.kwargs import ExtractRequired from ..interpreterbase.interpreterbase import TYPE_var, TYPE_kwargs from ..backends import InstallData - from typing_extensions import TypedDict + class PythonIntrospectionDict(TypedDict): + install_paths: T.Dict[str, str] + is_pypy: bool + is_venv: bool + link_libpython: bool + sysconfig_paths: T.Dict[str, str] + paths: T.Dict[str, str] + platform: str + suffix: str + variables: T.Dict[str, str] + version: str -mod_kwargs = {'subdir'} -mod_kwargs.update(known_shmod_kwargs) -mod_kwargs -= {'name_prefix', 'name_suffix'} + class PyInstallKw(TypedDict): + + pure: bool + subdir: str + install_tag: T.Optional[str] + class FindInstallationKw(ExtractRequired): + + disabler: bool + modules: T.List[str] -if T.TYPE_CHECKING: _Base = ExternalDependency else: _Base = object + +mod_kwargs = {'subdir'} +mod_kwargs.update(known_shmod_kwargs) +mod_kwargs -= {'name_prefix', 'name_suffix'} + + class _PythonDependencyBase(_Base): def __init__(self, python_holder: 'PythonInstallation', embed: bool): @@ -350,20 +374,6 @@ print(json.dumps({ })) ''' -if T.TYPE_CHECKING: - class PythonIntrospectionDict(TypedDict): - - install_paths: T.Dict[str, str] - is_pypy: bool - is_venv: bool - link_libpython: bool - sysconfig_paths: T.Dict[str, str] - paths: T.Dict[str, str] - platform: str - suffix: str - variables: T.Dict[str, str] - version: str - class PythonExternalProgram(ExternalProgram): def __init__(self, name: str, command: T.Optional[T.List[str]] = None, @@ -474,14 +484,6 @@ class PythonExternalProgram(ExternalProgram): _PURE_KW = KwargInfo('pure', bool, default=True) _SUBDIR_KW = KwargInfo('subdir', str, default='') -if T.TYPE_CHECKING: - - class PyInstallKw(TypedDict): - - pure: bool - subdir: str - install_tag: T.Optional[str] - class PythonInstallation(ExternalProgramHolder): def __init__(self, python: 'PythonExternalProgram', interpreter: 'Interpreter'): @@ -649,15 +651,6 @@ class PythonInstallation(ExternalProgramHolder): return super().path_method(args, kwargs) -if T.TYPE_CHECKING: - from ..interpreter.kwargs import ExtractRequired - - class FindInstallationKw(ExtractRequired): - - disabler: bool - modules: T.List[str] - - class PythonModule(ExtensionModule): @FeatureNew('Python Module', '0.46.0') |