aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/cmake/executor.py4
-rw-r--r--mesonbuild/cmake/interpreter.py6
-rw-r--r--mesonbuild/dependencies/cuda.py2
-rw-r--r--mesonbuild/environment.py5
-rw-r--r--mesonbuild/interpreter/type_checking.py11
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py38
-rw-r--r--mesonbuild/mlog.py5
-rw-r--r--mesonbuild/mtest.py16
-rw-r--r--mesonbuild/utils/core.py12
9 files changed, 45 insertions, 54 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py
index afd21ef..7482f54 100644
--- a/mesonbuild/cmake/executor.py
+++ b/mesonbuild/cmake/executor.py
@@ -33,8 +33,8 @@ if T.TYPE_CHECKING:
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram
-TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]]
-TYPE_cache_key = T.Tuple[str, T.Tuple[str, ...], str, T.FrozenSet[T.Tuple[str, str]]]
+ TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]]
+ TYPE_cache_key = T.Tuple[str, T.Tuple[str, ...], str, T.FrozenSet[T.Tuple[str, str]]]
class CMakeExecutor:
# The class's copy of the CMake path. Avoids having to search for it
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index f453aa3..f88d091 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -59,9 +59,9 @@ if T.TYPE_CHECKING:
from ..backend.backends import Backend
from ..environment import Environment
-TYPE_mixed = T.Union[str, int, bool, Path, BaseNode]
-TYPE_mixed_list = T.Union[TYPE_mixed, T.Sequence[TYPE_mixed]]
-TYPE_mixed_kwargs = T.Dict[str, TYPE_mixed_list]
+ TYPE_mixed = T.Union[str, int, bool, Path, BaseNode]
+ TYPE_mixed_list = T.Union[TYPE_mixed, T.Sequence[TYPE_mixed]]
+ TYPE_mixed_kwargs = T.Dict[str, TYPE_mixed_list]
# Disable all warnings automatically enabled with --trace and friends
# See https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_WARNING_CMPNNNN.html
diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py
index 8772427..89e562f 100644
--- a/mesonbuild/dependencies/cuda.py
+++ b/mesonbuild/dependencies/cuda.py
@@ -29,7 +29,7 @@ if T.TYPE_CHECKING:
from ..environment import Environment
from ..compilers import Compiler
-TV_ResultTuple = T.Tuple[T.Optional[str], T.Optional[str], bool]
+ TV_ResultTuple = T.Tuple[T.Optional[str], T.Optional[str], bool]
class CudaDependency(SystemDependency):
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 40629da..ae38ff4 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -51,9 +51,10 @@ if T.TYPE_CHECKING:
from .wrap.wrap import Resolver
-build_filename = 'meson.build'
+ CompilersDict = T.Dict[str, Compiler]
+
-CompilersDict = T.Dict[str, Compiler]
+build_filename = 'meson.build'
def _get_env_var(for_machine: MachineChoice, is_cross: bool, var_name: str) -> T.Optional[str]:
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index 0783c2c..7e1bd80 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -15,9 +15,8 @@ from ..coredata import UserFeatureOption
from ..dependencies import Dependency, InternalDependency
from ..interpreterbase import FeatureNew
from ..interpreterbase.decorators import KwargInfo, ContainerTypeInfo
-from ..mesonlib import (
- File, FileMode, MachineChoice, listify, has_path_sep, OptionKey,
- EnvInitValueType, EnvironmentVariables)
+from ..mesonlib import (File, FileMode, MachineChoice, listify, has_path_sep,
+ OptionKey, EnvironmentVariables)
from ..programs import ExternalProgram
# Helper definition for type checks that are `Optional[T]`
@@ -28,6 +27,10 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_var
from ..interpreterbase.decorators import FeatureCheckBase
+ from ..mesonlib import EnvInitValueType
+
+ _FullEnvInitValueType = T.Union[EnvironmentVariables, T.List[str], T.List[T.List[str]], EnvInitValueType, str, None]
+
def in_set_validator(choices: T.Set[str]) -> T.Callable[[str], T.Optional[str]]:
"""Check that the choice given was one of the given set."""
@@ -221,8 +224,6 @@ def split_equal_string(input: str) -> T.Tuple[str, str]:
a, b = input.split('=', 1)
return (a, b)
-_FullEnvInitValueType = T.Union[EnvironmentVariables, T.List[str], T.List[T.List[str]], EnvInitValueType, str, None]
-
# Split _env_convertor() and env_convertor_with_method() to make mypy happy.
# It does not want extra arguments in KwargInfo convertor callable.
def env_convertor_with_method(value: _FullEnvInitValueType,
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index 76fb465..f72ddc1 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -27,8 +27,6 @@ from .baseobjects import (
ObjectHolder,
IterableObject,
- TYPE_var,
-
HoldableTypes,
)
@@ -52,26 +50,26 @@ import typing as T
import textwrap
if T.TYPE_CHECKING:
- from .baseobjects import SubProject, TYPE_kwargs
+ from .baseobjects import SubProject, TYPE_kwargs, TYPE_var
from ..interpreter import Interpreter
-HolderMapType = T.Dict[
- T.Union[
- T.Type[mesonlib.HoldableObject],
- T.Type[int],
- T.Type[bool],
- T.Type[str],
- T.Type[list],
- T.Type[dict],
- ],
- # For some reason, this has to be a callable and can't just be ObjectHolder[InterpreterObjectTypeVar]
- T.Callable[[InterpreterObjectTypeVar, 'Interpreter'], ObjectHolder[InterpreterObjectTypeVar]]
-]
-
-FunctionType = T.Dict[
- str,
- T.Callable[[mparser.BaseNode, T.List[TYPE_var], T.Dict[str, TYPE_var]], TYPE_var]
-]
+ HolderMapType = T.Dict[
+ T.Union[
+ T.Type[mesonlib.HoldableObject],
+ T.Type[int],
+ T.Type[bool],
+ T.Type[str],
+ T.Type[list],
+ T.Type[dict],
+ ],
+ # For some reason, this has to be a callable and can't just be ObjectHolder[InterpreterObjectTypeVar]
+ T.Callable[[InterpreterObjectTypeVar, 'Interpreter'], ObjectHolder[InterpreterObjectTypeVar]]
+ ]
+
+ FunctionType = T.Dict[
+ str,
+ T.Callable[[mparser.BaseNode, T.List[TYPE_var], T.Dict[str, TYPE_var]], TYPE_var]
+ ]
class InterpreterBase:
def __init__(self, source_root: str, subdir: str, subproject: 'SubProject'):
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index b778bfa..471934f 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -31,6 +31,8 @@ if T.TYPE_CHECKING:
from .mparser import BaseNode
+ TV_Loggable = T.Union[str, 'AnsiDecorator', StringProtocol]
+ TV_LoggableList = T.List[TV_Loggable]
"""This is (mostly) a standalone module used to write logging
information about Meson runs. Some output goes to screen,
@@ -153,9 +155,6 @@ class AnsiDecorator:
def __str__(self) -> str:
return self.get_text(colorize_console())
-TV_Loggable = T.Union[str, AnsiDecorator, 'StringProtocol']
-TV_LoggableList = T.List[TV_Loggable]
-
class AnsiText:
def __init__(self, *args: 'SizedStringProtocol'):
self.args = args
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index a46125d..1feb205 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -51,6 +51,15 @@ from .mintro import get_infodir, load_info_file
from .programs import ExternalProgram
from .backend.backends import TestProtocol, TestSerialisation
+if T.TYPE_CHECKING:
+ TYPE_TAPResult = T.Union['TAPParser.Test',
+ 'TAPParser.Error',
+ 'TAPParser.Version',
+ 'TAPParser.Plan',
+ 'TAPParser.UnknownLine',
+ 'TAPParser.Bailout']
+
+
# GNU autotools interprets a return code of 77 from tests it executes to
# mean that the test should be skipped.
GNU_SKIP_RETURNCODE = 77
@@ -272,13 +281,6 @@ class TestResult(enum.Enum):
return str(self.colorize('>>> '))
-TYPE_TAPResult = T.Union['TAPParser.Test',
- 'TAPParser.Error',
- 'TAPParser.Version',
- 'TAPParser.Plan',
- 'TAPParser.UnknownLine',
- 'TAPParser.Bailout']
-
class TAPParser:
class Plan(T.NamedTuple):
num_tests: int
diff --git a/mesonbuild/utils/core.py b/mesonbuild/utils/core.py
index b0c2b31..4398413 100644
--- a/mesonbuild/utils/core.py
+++ b/mesonbuild/utils/core.py
@@ -34,15 +34,7 @@ if T.TYPE_CHECKING:
EnvironOrDict = T.Union[T.Dict[str, str], os._Environ[str]]
-
-__all__ = [
- 'MesonException',
- 'MesonBugException',
- 'HoldableObject',
- 'EnvInitValueType',
- 'EnvironmentVariables',
- 'ExecutableSerialisation',
-]
+ EnvInitValueType = T.Dict[str, T.Union[str, T.List[str]]]
class MesonException(Exception):
@@ -76,8 +68,6 @@ class HoldableObject(metaclass=abc.ABCMeta):
''' Dummy base class for all objects that can be
held by an interpreter.baseobjects.ObjectHolder '''
-EnvInitValueType = T.Dict[str, T.Union[str, T.List[str]]]
-
class EnvironmentVariables(HoldableObject):
def __init__(self, values: T.Optional[EnvInitValueType] = None,
init_method: Literal['set', 'prepend', 'append'] = 'set', separator: str = os.pathsep) -> None: