flake8: move unused typing-only imports to TYPE_CHECKING

pull/13483/head
Eli Schwartz 6 months ago
parent 574fbe7d95
commit 4a352dd8bd
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/ast/interpreter.py
  2. 7
      mesonbuild/compilers/compilers.py
  3. 2
      mesonbuild/compilers/d.py
  4. 2
      mesonbuild/compilers/mixins/emscripten.py
  5. 2
      mesonbuild/compilers/objc.py
  6. 2
      mesonbuild/compilers/objcpp.py
  7. 2
      mesonbuild/compilers/vala.py
  8. 2
      mesonbuild/coredata.py
  9. 2
      mesonbuild/mformat.py
  10. 3
      mesonbuild/modules/python3.py
  11. 2
      mesonbuild/optinterpreter.py

@ -43,7 +43,6 @@ from ..mparser import (
NotNode, NotNode,
PlusAssignmentNode, PlusAssignmentNode,
TernaryNode, TernaryNode,
TestCaseClauseNode,
) )
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
@ -57,6 +56,7 @@ if T.TYPE_CHECKING:
IfClauseNode, IfClauseNode,
IndexNode, IndexNode,
OrNode, OrNode,
TestCaseClauseNode,
UMinusNode, UMinusNode,
) )

@ -12,7 +12,6 @@ import typing as T
from dataclasses import dataclass from dataclasses import dataclass
from functools import lru_cache from functools import lru_cache
from .. import coredata
from .. import mlog from .. import mlog
from .. import mesonlib from .. import mesonlib
from .. import options from .. import options
@ -27,7 +26,7 @@ from ..options import OptionKey
from ..arglist import CompilerArgs from ..arglist import CompilerArgs
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from typing import Any from .. import coredata
from ..build import BuildTarget, DFeatures from ..build import BuildTarget, DFeatures
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
@ -1360,7 +1359,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def get_global_options(lang: str, def get_global_options(lang: str,
comp: T.Type[Compiler], comp: T.Type[Compiler],
for_machine: MachineChoice, for_machine: MachineChoice,
env: 'Environment') -> 'dict[OptionKey, options.UserOption[Any]]': env: 'Environment') -> dict[OptionKey, options.UserOption[T.Any]]:
"""Retrieve options that apply to all compilers for a given language.""" """Retrieve options that apply to all compilers for a given language."""
description = f'Extra arguments passed to the {lang}' description = f'Extra arguments passed to the {lang}'
argkey = OptionKey(f'{lang}_args', machine=for_machine) argkey = OptionKey(f'{lang}_args', machine=for_machine)
@ -1390,6 +1389,6 @@ def get_global_options(lang: str,
# autotools compatibility. # autotools compatibility.
largs.extend_value(comp_options) largs.extend_value(comp_options)
opts: 'dict[OptionKey, options.UserOption[Any]]' = {argkey: cargs, largkey: largs} opts: dict[OptionKey, options.UserOption[T.Any]] = {argkey: cargs, largkey: largs}
return opts return opts

@ -16,7 +16,6 @@ from ..mesonlib import (
) )
from ..options import OptionKey from ..options import OptionKey
from . import compilers
from .compilers import ( from .compilers import (
clike_debug_args, clike_debug_args,
Compiler, Compiler,
@ -26,6 +25,7 @@ from .mixins.gnu import GnuCompiler
from .mixins.gnu import gnu_common_warning_args from .mixins.gnu import gnu_common_warning_args
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from . import compilers
from ..build import DFeatures from ..build import DFeatures
from ..dependencies import Dependency from ..dependencies import Dependency
from ..envconfig import MachineInfo from ..envconfig import MachineInfo

@ -8,7 +8,6 @@ from __future__ import annotations
import os.path import os.path
import typing as T import typing as T
from ... import coredata
from ... import options from ... import options
from ... import mesonlib from ... import mesonlib
from ...options import OptionKey from ...options import OptionKey
@ -16,6 +15,7 @@ from ...mesonlib import LibType
from mesonbuild.compilers.compilers import CompileCheckMode from mesonbuild.compilers.compilers import CompileCheckMode
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ... import coredata
from ...environment import Environment from ...environment import Environment
from ...compilers.compilers import Compiler from ...compilers.compilers import Compiler
from ...dependencies import Dependency from ...dependencies import Dependency

@ -5,7 +5,6 @@ from __future__ import annotations
import typing as T import typing as T
from .. import coredata
from .. import options from .. import options
from ..options import OptionKey from ..options import OptionKey
@ -15,6 +14,7 @@ from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_a
from .mixins.clang import ClangCompiler from .mixins.clang import ClangCompiler
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from .. import coredata
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
from ..environment import Environment from ..environment import Environment
from ..linkers.linkers import DynamicLinker from ..linkers.linkers import DynamicLinker

@ -5,7 +5,6 @@ from __future__ import annotations
import typing as T import typing as T
from .. import coredata
from .. import options from .. import options
from ..options import OptionKey from ..options import OptionKey
@ -15,6 +14,7 @@ from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_a
from .mixins.clang import ClangCompiler from .mixins.clang import ClangCompiler
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from .. import coredata
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
from ..environment import Environment from ..environment import Environment
from ..linkers.linkers import DynamicLinker from ..linkers.linkers import DynamicLinker

@ -11,9 +11,9 @@ from .. import mesonlib
from ..mesonlib import EnvironmentException, version_compare, LibType from ..mesonlib import EnvironmentException, version_compare, LibType
from ..options import OptionKey from ..options import OptionKey
from .compilers import CompileCheckMode, Compiler from .compilers import CompileCheckMode, Compiler
from ..arglist import CompilerArgs
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ..arglist import CompilerArgs
from ..coredata import KeyedOptionDictType from ..coredata import KeyedOptionDictType
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
from ..environment import Environment from ..environment import Environment

@ -27,12 +27,12 @@ from .options import OptionKey
from .machinefile import CmdLineFileParser from .machinefile import CmdLineFileParser
import ast import ast
import argparse
import enum import enum
import shlex import shlex
import typing as T import typing as T
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
import argparse
from typing_extensions import Protocol from typing_extensions import Protocol
from typing import Any from typing import Any

@ -3,7 +3,6 @@
from __future__ import annotations from __future__ import annotations
import argparse
import re import re
import typing as T import typing as T
from configparser import ConfigParser, MissingSectionHeaderError, ParsingError from configparser import ConfigParser, MissingSectionHeaderError, ParsingError
@ -19,6 +18,7 @@ from .ast.visitor import FullAstVisitor
from .environment import build_filename from .environment import build_filename
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
import argparse
from typing_extensions import Literal from typing_extensions import Literal

@ -7,7 +7,7 @@ import sysconfig
import typing as T import typing as T
from .. import mesonlib from .. import mesonlib
from . import ExtensionModule, ModuleInfo, ModuleState from . import ExtensionModule, ModuleInfo
from ..build import ( from ..build import (
BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects,
GeneratedList, SharedModule, StructuredSources, known_shmod_kwargs GeneratedList, SharedModule, StructuredSources, known_shmod_kwargs
@ -17,6 +17,7 @@ from ..interpreterbase import typed_kwargs, typed_pos_args, noPosargs, noKwargs,
from ..programs import ExternalProgram from ..programs import ExternalProgram
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from . import ModuleState
from ..interpreter.interpreter import BuildTargetSource from ..interpreter.interpreter import BuildTargetSource
from ..interpreter.kwargs import SharedModule as SharedModuleKW from ..interpreter.kwargs import SharedModule as SharedModuleKW

@ -6,7 +6,6 @@ from __future__ import annotations
import re import re
import typing as T import typing as T
from . import coredata
from . import options from . import options
from . import mesonlib from . import mesonlib
from .options import OptionKey from .options import OptionKey
@ -16,6 +15,7 @@ from .interpreterbase import FeatureNew, FeatureDeprecated, typed_pos_args, type
from .interpreter.type_checking import NoneType, in_set_validator from .interpreter.type_checking import NoneType, in_set_validator
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from . import coredata
from .interpreterbase import TYPE_var, TYPE_kwargs from .interpreterbase import TYPE_var, TYPE_kwargs
from .interpreterbase import SubProject from .interpreterbase import SubProject
from typing_extensions import TypedDict, Literal from typing_extensions import TypedDict, Literal

Loading…
Cancel
Save