move various unused typing-only imports into type-checking blocks

pull/10489/head
Eli Schwartz 2 years ago
parent 46148f923b
commit 0703ee0aef
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 22
      mesonbuild/ast/interpreter.py
  2. 5
      mesonbuild/ast/postprocess.py
  3. 6
      mesonbuild/ast/visitor.py
  4. 5
      mesonbuild/build.py
  5. 7
      mesonbuild/cmake/executor.py
  6. 7
      mesonbuild/cmake/interpreter.py
  7. 3
      mesonbuild/cmake/toolchain.py
  8. 4
      mesonbuild/compilers/compilers.py
  9. 6
      mesonbuild/compilers/cpp.py
  10. 7
      mesonbuild/compilers/cuda.py
  11. 4
      mesonbuild/compilers/d.py
  12. 4
      mesonbuild/compilers/fortran.py
  13. 4
      mesonbuild/compilers/java.py
  14. 4
      mesonbuild/compilers/objc.py
  15. 4
      mesonbuild/compilers/swift.py
  16. 4
      mesonbuild/compilers/vala.py
  17. 11
      mesonbuild/mintro.py
  18. 1
      mesonbuild/modules/__init__.py
  19. 3
      mesonbuild/modules/gnome.py

@ -14,12 +14,12 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool.
from __future__ import annotations
import os
import sys
import typing as T
from .visitor import AstVisitor
from .. import mparser, mesonlib
from .. import environment
@ -30,8 +30,6 @@ from ..interpreterbase import (
BreakRequest,
ContinueRequest,
default_resolve_key,
TYPE_nvar,
TYPE_nkwargs,
)
from ..interpreter import (
@ -43,29 +41,33 @@ from ..interpreter import (
)
from ..mparser import (
AndNode,
ArgumentNode,
ArithmeticNode,
ArrayNode,
AssignmentNode,
BaseNode,
ComparisonNode,
ElementaryNode,
EmptyNode,
ForeachClauseNode,
IdNode,
IfClauseNode,
IndexNode,
MethodNode,
NotNode,
OrNode,
PlusAssignmentNode,
TernaryNode,
UMinusNode,
)
if T.TYPE_CHECKING:
from .visitor import AstVisitor
from ..interpreter import Interpreter
from ..interpreterbase import TYPE_nkwargs, TYPE_nvar
from ..mparser import (
AndNode,
ComparisonNode,
ForeachClauseNode,
IfClauseNode,
IndexNode,
OrNode,
UMinusNode,
)
class DontCareObject(MesonInterpreterObject):
pass

@ -14,11 +14,14 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool
from __future__ import annotations
from . import AstVisitor
from .. import mparser
import typing as T
if T.TYPE_CHECKING:
from .. import mparser
class AstIndentationGenerator(AstVisitor):
def __init__(self) -> None:
self.level = 0

@ -14,8 +14,12 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool
from __future__ import annotations
from .. import mparser
import typing as T
if T.TYPE_CHECKING:
from .. import mparser
class AstVisitor:
def __init__(self) -> None:

@ -39,18 +39,19 @@ from .mesonlib import (
MesonBugException
)
from .compilers import (
Compiler, is_object, clink_langs, sort_clink, lang_suffixes, all_languages,
is_object, clink_langs, sort_clink, lang_suffixes, all_languages,
is_known_suffix, detect_static_linker
)
from .linkers import StaticLinker
from .interpreterbase import FeatureNew, FeatureDeprecated
if T.TYPE_CHECKING:
from typing_extensions import Literal
from ._typing import ImmutableListProtocol
from .backend.backends import Backend, ExecutableSerialisation
from .compilers import Compiler
from .interpreter.interpreter import Test, SourceOutputs, Interpreter
from .interpreterbase import SubProject
from .linkers import StaticLinker
from .mesonlib import FileMode, FileOrString
from .modules import ModuleState
from .mparser import BaseNode

@ -14,20 +14,23 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool.
from __future__ import annotations
import subprocess as S
from pathlib import Path
from threading import Thread
import typing as T
import re
import os
from .. import mlog
from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice, is_windows, OptionKey
from ..mesonlib import PerMachine, Popen_safe, version_compare, is_windows, OptionKey
from ..programs import find_external_program, NonExistingExternalProgram
if T.TYPE_CHECKING:
from pathlib import Path
from ..environment import Environment
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram
TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]]

@ -14,6 +14,7 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool.
from __future__ import annotations
from functools import lru_cache
from os import environ
@ -21,11 +22,11 @@ from pathlib import Path
import re
import typing as T
from .common import CMakeException, CMakeTarget, TargetOptions, CMakeConfiguration, language_map, cmake_get_generator_args, check_cmake_args
from .common import CMakeException, CMakeTarget, language_map, cmake_get_generator_args, check_cmake_args
from .fileapi import CMakeFileAPI
from .executor import CMakeExecutor
from .toolchain import CMakeToolchain, CMakeExecScope
from .traceparser import CMakeTraceParser, CMakeGeneratorTarget
from .traceparser import CMakeTraceParser
from .tracetargets import resolve_cmake_trace_targets
from .. import mlog, mesonlib
from ..mesonlib import MachineChoice, OrderedSet, path_is_in_root, relative_to_if_possible, OptionKey
@ -51,6 +52,8 @@ from ..mparser import (
if T.TYPE_CHECKING:
from .common import CMakeConfiguration, TargetOptions
from .traceparser import CMakeGeneratorTarget
from .._typing import ImmutableListProtocol
from ..build import Build
from ..backend.backends import Backend

@ -11,11 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
from pathlib import Path
from .traceparser import CMakeTraceParser
from ..envconfig import CMakeSkipCompilerTest
from ..mesonlib import MachineChoice
from ..compilers import VisualStudioLikeCompiler
from .common import language_map, cmake_get_generator_args
from .. import mlog
@ -29,6 +29,7 @@ if T.TYPE_CHECKING:
from .executor import CMakeExecutor
from ..environment import Environment
from ..compilers import Compiler
from ..mesonlib import MachineChoice
class CMakeExecScope(Enum):
SUBPROJECT = 'subproject'

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import abc
import contextlib, os.path, re
@ -24,7 +25,7 @@ from .. import mlog
from .. import mesonlib
from ..mesonlib import (
HoldableObject,
EnvironmentException, MachineChoice, MesonException,
EnvironmentException, MesonException,
Popen_safe, LibType, TemporaryDirectoryWinProof, OptionKey,
)
@ -36,6 +37,7 @@ if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker, RSPFileSyntax
from ..mesonlib import MachineChoice
from ..dependencies import Dependency
CompilerType = T.TypeVar('CompilerType', bound='Compiler')

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import copy
import functools
@ -19,13 +20,12 @@ import typing as T
from .. import coredata
from .. import mlog
from ..mesonlib import MesonException, MachineChoice, version_compare, OptionKey
from ..mesonlib import MesonException, version_compare, OptionKey
from .compilers import (
gnu_winlibs,
msvc_winlibs,
Compiler,
CompileCheckMode,
)
from .c_function_attributes import CXX_FUNC_ATTRIBUTES, C_FUNC_ATTRIBUTES
from .mixins.clike import CLikeCompiler
@ -41,11 +41,13 @@ from .mixins.pgi import PGICompiler
from .mixins.emscripten import EmscriptenMixin
if T.TYPE_CHECKING:
from .compilers import CompileCheckMode
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
from ..dependencies import Dependency
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram
CompilerMixinBase = CLikeCompiler
else:

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import enum
import os.path
@ -20,19 +21,21 @@ import typing as T
from .. import coredata
from .. import mlog
from ..mesonlib import (
EnvironmentException, MachineChoice, Popen_safe, OptionOverrideProxy,
EnvironmentException, Popen_safe, OptionOverrideProxy,
is_windows, LibType, OptionKey,
)
from .compilers import (Compiler, cuda_buildtype_args, cuda_optimization_args,
cuda_debug_args, CompileCheckMode)
cuda_debug_args)
if T.TYPE_CHECKING:
from .compilers import CompileCheckMode
from ..build import BuildTarget
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
from ..dependencies import Dependency
from ..environment import Environment # noqa: F401
from ..envconfig import MachineInfo
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import os.path
import re
@ -22,7 +23,7 @@ from .. import mlog
from ..arglist import CompilerArgs
from ..linkers import RSPFileSyntax
from ..mesonlib import (
EnvironmentException, MachineChoice, version_compare, OptionKey, is_windows
EnvironmentException, version_compare, OptionKey, is_windows
)
from . import compilers
@ -42,6 +43,7 @@ if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
CompilerMixinBase = Compiler
else:

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
from pathlib import Path
import typing as T
@ -31,7 +32,7 @@ from .mixins.elbrus import ElbrusCompiler
from .mixins.pgi import PGICompiler
from mesonbuild.mesonlib import (
version_compare, EnvironmentException, MesonException, MachineChoice,
version_compare, EnvironmentException, MesonException,
LibType, OptionKey,
)
@ -41,6 +42,7 @@ if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram
from .compilers import CompileCheckMode

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import os
import os.path
@ -19,13 +20,14 @@ import subprocess
import textwrap
import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
from ..mesonlib import EnvironmentException
from .compilers import Compiler, java_buildtype_args
from .mixins.islinker import BasicLinkerIsCompilerMixin
if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..mesonlib import MachineChoice
class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):

@ -11,11 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import typing as T
from .. import coredata
from ..mesonlib import MachineChoice, OptionKey
from ..mesonlib import OptionKey
from .compilers import Compiler
from .mixins.clike import CLikeCompiler
@ -27,6 +28,7 @@ if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
class ObjCCompiler(CLikeCompiler, Compiler):

@ -11,11 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import subprocess, os.path
import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
from ..mesonlib import EnvironmentException
from .compilers import Compiler, swift_buildtype_args, clike_debug_args
@ -23,6 +24,7 @@ if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
swift_optimization_args = {
'0': [],

@ -11,18 +11,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import os.path
import typing as T
from .. import mlog
from ..mesonlib import EnvironmentException, MachineChoice, version_compare, OptionKey
from ..mesonlib import EnvironmentException, version_compare, OptionKey
from .compilers import Compiler, LibType
if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment
from ..mesonlib import MachineChoice
class ValaCompiler(Compiler):

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
"""This is a helper script for IDE developers. It allows you to
extract information such as list of targets, files, compiler flags,
@ -19,7 +20,6 @@ tests and so on. All output is in JSON for simple parsing.
Currently only works for the Ninja backend. Others use generated
project files and don't need this info."""
import argparse
import collections
import json
import os
@ -29,9 +29,14 @@ import typing as T
from . import build, mesonlib, mlog, coredata as cdata
from .ast import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstJSONPrinter
from .backend import backends
from .interpreter import Interpreter
from .mesonlib import OptionKey
from .mparser import BaseNode, FunctionNode, ArrayNode, ArgumentNode, StringNode
from .mparser import FunctionNode, ArrayNode, ArgumentNode, StringNode
if T.TYPE_CHECKING:
import argparse
from .interpreter import Interpreter
from .mparser import BaseNode
def get_meson_info_file(info_dir: str) -> str:
return os.path.join(info_dir, 'meson-info.json')

@ -23,6 +23,7 @@ from ..interpreterbase.decorators import noKwargs, noPosargs
from ..programs import ExternalProgram
if T.TYPE_CHECKING:
from .. import build
from ..interpreter import Interpreter
from ..interpreter.interpreterobjects import MachineHolder
from ..interpreterbase import TYPE_var, TYPE_kwargs

@ -39,7 +39,7 @@ from ..interpreterbase.decorators import typed_pos_args
from ..mesonlib import (
MachineChoice, MesonException, OrderedSet, Popen_safe, join_args,
)
from ..programs import ExternalProgram, OverrideProgram, EmptyExternalProgram
from ..programs import OverrideProgram, EmptyExternalProgram
from ..scripts.gettext import read_linguas
if T.TYPE_CHECKING:
@ -51,6 +51,7 @@ if T.TYPE_CHECKING:
from ..interpreter import Interpreter
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..mesonlib import FileOrString
from ..programs import ExternalProgram
class PostInstall(TypedDict):
glib_compile_schemas: bool

Loading…
Cancel
Save