diff --git a/mesonbuild/build.py b/mesonbuild/build.py index d588c9db8..6438b836d 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -26,7 +26,6 @@ import textwrap import typing as T from . import coredata -from . import environment from . import dependencies from . import mlog from . import programs @@ -46,6 +45,8 @@ from .interpreterbase import FeatureNew, FeatureDeprecated if T.TYPE_CHECKING: from typing_extensions import Literal + + from . import environment from ._typing import ImmutableListProtocol from .backend.backends import Backend from .compilers import Compiler diff --git a/mesonbuild/cargo/builder.py b/mesonbuild/cargo/builder.py index 49bc65db5..fb086d164 100644 --- a/mesonbuild/cargo/builder.py +++ b/mesonbuild/cargo/builder.py @@ -8,12 +8,14 @@ build descriptions easier. """ from __future__ import annotations -import builtins import dataclasses import typing as T from .. import mparser +if T.TYPE_CHECKING: + import builtins + def _token(tid: str, filename: str, value: mparser.TV_TokenTypes) -> mparser.Token[mparser.TV_TokenTypes]: """Create a Token object, but with the line numbers stubbed out. diff --git a/mesonbuild/cargo/interpreter.py b/mesonbuild/cargo/interpreter.py index 59e1a1f06..8848a46a8 100644 --- a/mesonbuild/cargo/interpreter.py +++ b/mesonbuild/cargo/interpreter.py @@ -21,7 +21,6 @@ import typing as T from . import builder from . import version -from .. import mparser from .._pathlib import Path from ..mesonlib import MesonException, Popen_safe @@ -29,6 +28,7 @@ if T.TYPE_CHECKING: from types import ModuleType from . import manifest + from .. import mparser from ..environment import Environment # tomllib is present in python 3.11, before that it is a pypi module called tomli, diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index ce7c9f1e6..3ec771315 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -33,7 +33,6 @@ from .envconfig import ( ) from . import compilers from .compilers import ( - Compiler, is_assembly, is_header, is_library, @@ -49,6 +48,7 @@ if T.TYPE_CHECKING: import argparse from configparser import ConfigParser + from .compilers import Compiler from .wrap.wrap import Resolver CompilersDict = T.Dict[str, Compiler] diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py index d039f6dfb..9aff5b971 100644 --- a/mesonbuild/interpreterbase/interpreterbase.py +++ b/mesonbuild/interpreterbase/interpreterbase.py @@ -22,7 +22,6 @@ from .baseobjects import ( InterpreterObject, MesonInterpreterObject, MutableInterpreterObject, - InterpreterObjectTypeVar, ObjectHolder, IterableObject, ContextManagerObject, @@ -50,7 +49,7 @@ import typing as T import textwrap if T.TYPE_CHECKING: - from .baseobjects import SubProject, TYPE_kwargs, TYPE_var + from .baseobjects import InterpreterObjectTypeVar, SubProject, TYPE_kwargs, TYPE_var from ..interpreter import Interpreter HolderMapType = T.Dict[ diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 1d1e858ac..063c5cdd6 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -429,7 +429,7 @@ def list_deps(coredata: cdata.CoreData, backend: backends.Backend) -> T.List[T.D d = holder.held_object if isinstance(d, Dependency) and d.found(): if d.name in result: - T.cast(T.List[str], result[d.name]['meson_variables']).append(varname) + T.cast('T.List[str]', result[d.name]['meson_variables']).append(varname) else: result[d.name] = _create_result(d, varname) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 1f05f08d4..f6c82e0d6 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -333,7 +333,7 @@ class PythonModule(ExtensionModule): for i in self.installations.values(): if isinstance(i, PythonExternalProgram) and i.run_bytecompile[i.info['version']]: - i = T.cast(PythonExternalProgram, i) + i = T.cast('PythonExternalProgram', i) manifest = f'python-{i.info["version"]}-installed.json' manifest_json = [] for name, f in py_files: diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 3514412e6..4f5494af3 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -18,16 +18,16 @@ import typing as T from . import ExtensionModule, ModuleReturnValue, ModuleInfo from .. import mlog -from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, InvalidArguments, Jar, StructuredSources +from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, CustomTarget, InvalidArguments, Jar, StructuredSources from ..compilers.compilers import are_asserts_disabled -from ..dependencies import Dependency, ExternalLibrary from ..interpreter.type_checking import DEPENDENCIES_KW, LINK_WITH_KW, TEST_KWS, OUTPUT_KW, INCLUDE_DIRECTORIES from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs from ..mesonlib import File if T.TYPE_CHECKING: from . import ModuleState - from ..build import LibTypes + from ..build import IncludeDirs, LibTypes + from ..dependencies import Dependency, ExternalLibrary from ..interpreter import Interpreter from ..interpreter import kwargs as _kwargs from ..interpreter.interpreter import SourceInputs, SourceOutputs diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index 3ecfba18f..d1b51f048 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.py @@ -16,12 +16,14 @@ import zipfile from . import mlog from .ast import IntrospectionInterpreter, AstIDGenerator from .mesonlib import quiet_git, GitException, Popen_safe, MesonException, windows_proof_rmtree -from .wrap.wrap import (Resolver, WrapException, ALL_TYPES, PackageDefinition, +from .wrap.wrap import (Resolver, WrapException, ALL_TYPES, parse_patch_url, update_wrap_file, get_releases) if T.TYPE_CHECKING: from typing_extensions import Protocol + from .wrap.wrap import PackageDefinition + SubParsers = argparse._SubParsersAction[argparse.ArgumentParser] class Arguments(Protocol):