Skip to content

Commit

Permalink
dependencies: Use a TypedDict for Dependency keyword arguments
Browse files Browse the repository at this point in the history
There are a couple of annoyances around the way Python's TypedDicts work
that we should get out of the way:

1) A TypedDict keeps it's `total` status, so you can't do something
   like:
   ```python
   from interpreter.type_checking import FuncDependency

   class DependencyKWs(FuncDependency, total=False): pass
   ```

   All of the arguments from FuncDependency remain required.
2) The "functional" form of `TypedDict` requires a literal for it's
   arguments, so you can't do something like:
   ```python
   _VALUES = {...}
   FuncDependency = TypedDict('FuncDependency', _VALUES)
   DependencyKWs = TypedDict('DependencyKWs', _VALUES, total=False)

And, there are some arguments `dependency()` that are not passed to the
lower levels, but are interpreter constructs. Likewise, some of the
Dependency classes take additional kwargs that are not part of the
dependency() DSL API. So we have to have two different TypedDicts, which
is unfortunate.

Additionally, TypedDicts must define all allowed keys, there is no way
to define "extra keys". This means that implementing this change as a
series of small commits would would require hundreds of `# type: ignore`
comments to be introduced and removed across the range. That kind of
noise seems counterproductive to the purpose of having small commits,
since there will end up being loads of churn introduced by such a series
of commits.
  • Loading branch information
dcbaker committed Dec 13, 2024
1 parent 7c76ef2 commit 4fde72c
Show file tree
Hide file tree
Showing 24 changed files with 188 additions and 138 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.
```python
class FooSystemDependency(ExternalDependency):
def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]):
def __init__(self, name: str, environment: Environment, kwargs: DependencyKWs):
super().__init__(name, environment, kwargs)
root = environment.properties[self.for_machine].foo_root
if root is None:
Expand Down
60 changes: 48 additions & 12 deletions mesonbuild/dependencies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#from ..interpreterbase import FeatureDeprecated, FeatureNew

if T.TYPE_CHECKING:
from typing_extensions import Literal
from typing_extensions import Literal, TypedDict

from ..compilers.compilers import Compiler
from ..environment import Environment
Expand All @@ -32,6 +32,44 @@
)
from ..interpreter.type_checking import PkgConfigDefineType

# This must be kept in sync with the FuncDependency class in
# interpreter.type_checking
# They cannot share in anyway due to the way total works
class DependencyKWs(TypedDict, total=False):

# The following arguments to `dependency()` are used in the interpreter,
# and are not needed here:
# - allow_fallback
# - default_options
# - fallback
# - not_found_message

cmake_args: T.List[str]
cmake_module_path: T.List[str]
cmake_package_version: str
components: T.List[str]
embed: bool
include_type: Literal['system', 'non-system', 'preserve']
language: T.Optional[str] # TODO: use a shared literal?
main: bool
method: str
modules: T.List[str]
native: MachineChoice
optional_modules: T.List[str]
private_headers: bool
required: bool
static: T.Optional[bool]
version: T.List[str]

# These options only exist as implementation details to Dependency
# classes, and are not available to the DSL
silent: bool
tools: T.List[str]
returncode_value: int
paths: T.List[str]
version_arg: str
skip_version: str

_MissingCompilerBase = Compiler
else:
_MissingCompilerBase = object
Expand Down Expand Up @@ -99,7 +137,7 @@ class DependencyMethods(Enum):

class Dependency(HoldableObject):

def __init__(self, type_name: DependencyTypeName, kwargs: T.Dict[str, T.Any]) -> None:
def __init__(self, type_name: DependencyTypeName, kwargs: DependencyKWs) -> None:
# This allows two Dependencies to be compared even after being copied.
# The purpose is to allow the name to be changed, but still have a proper comparison
self._id = uuid.uuid4().int
Expand Down Expand Up @@ -373,25 +411,23 @@ def get_as_shared(self, recursive: bool) -> InternalDependency:
return new_dep

class ExternalDependency(Dependency):

Check warning

Code scanning / CodeQL

`__eq__` not overridden when adding attributes Warning

The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
env
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
name
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
is_found
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
language
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
version_reqs
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
required
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
silent
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
static
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
libtype
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
for_machine
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
clib_compiler
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
is_found
.
The class 'ExternalDependency' does not override
'__eq__'
, but adds the new attribute
is_found
.
def __init__(self, type_name: DependencyTypeName, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None):
def __init__(self, type_name: DependencyTypeName, environment: 'Environment', kwargs: DependencyKWs, language: T.Optional[str] = None):
Dependency.__init__(self, type_name, kwargs)
self.env = environment
self.name = type_name # default
self.is_found = False
self.language = language
version_reqs = kwargs.get('version', None)
if isinstance(version_reqs, str):
version_reqs = [version_reqs]
self.version_reqs: T.Optional[T.List[str]] = version_reqs
self.version_reqs = version_reqs
self.required = kwargs.get('required', True)
self.silent = kwargs.get('silent', False)
static = kwargs.get('static')
if static is None:
static = self.env.coredata.get_option(OptionKey('prefer_static'))
self.static = T.cast('bool', static)
static = T.cast('bool', self.env.coredata.get_option(OptionKey('prefer_static')))
self.static = static
self.libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED
# Is this dependency to be run on the build platform?
self.for_machine = T.cast('MachineChoice', kwargs.get('native', MachineChoice.HOST))
self.for_machine = kwargs.get('native', MachineChoice.HOST)
self.clib_compiler = detect_compiler(self.name, environment, self.for_machine, self.language)

def get_compiler(self) -> T.Union['MissingCompiler', 'Compiler']:
Expand Down Expand Up @@ -580,7 +616,7 @@ def strip_system_includedirs(environment: 'Environment', for_machine: MachineCho
exclude = {f'-I{p}' for p in environment.get_compiler_system_include_dirs(for_machine)}
return [i for i in include_args if i not in exclude]

def process_method_kw(possible: T.Iterable[DependencyMethods], kwargs: T.Dict[str, T.Any]) -> T.List[DependencyMethods]:
def process_method_kw(possible: T.Iterable[DependencyMethods], kwargs: DependencyKWs) -> T.List[DependencyMethods]:
method: T.Union[DependencyMethods, str] = kwargs.get('method', 'auto')
if isinstance(method, DependencyMethods):
return [method]
Expand Down Expand Up @@ -646,7 +682,7 @@ class SystemDependency(ExternalDependency):

"""Dependency base for System type dependencies."""

def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],
def __init__(self, name: str, env: 'Environment', kwargs: DependencyKWs,
language: T.Optional[str] = None) -> None:
super().__init__(DependencyTypeName('system'), env, kwargs, language=language)
self.name = name
Expand All @@ -660,7 +696,7 @@ class BuiltinDependency(ExternalDependency):

"""Dependency base for Builtin type dependencies."""

def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],
def __init__(self, name: str, env: 'Environment', kwargs: DependencyKWs,
language: T.Optional[str] = None) -> None:
super().__init__(DependencyTypeName('builtin'), env, kwargs, language=language)
self.name = name
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/dependencies/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .misc import threads_factory

if T.TYPE_CHECKING:
from .base import DependencyKWs
from ..envconfig import Properties
from ..environment import Environment

Expand Down Expand Up @@ -339,7 +340,7 @@ def get_link_args(self) -> T.List[str]:
return [self.path.as_posix()]

class BoostDependency(SystemDependency):
def __init__(self, environment: Environment, kwargs: T.Dict[str, T.Any]) -> None:
def __init__(self, environment: Environment, kwargs: DependencyKWs) -> None:
super().__init__('boost', environment, kwargs, language='cpp')
buildtype = environment.coredata.get_option(OptionKey('buildtype'))
assert isinstance(buildtype, str)
Expand Down
19 changes: 10 additions & 9 deletions mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import typing as T

if T.TYPE_CHECKING:
from .base import DependencyKWs

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.cmake
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.cmake.
from ..cmake import CMakeTarget
from ..environment import Environment
from ..envconfig import MachineInfo
Expand Down Expand Up @@ -69,11 +70,11 @@ def _original_module_name(self, module: str) -> str:
# one module
return module

def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> None:
def __init__(self, name: str, environment: 'Environment', kwargs: DependencyKWs, language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> None:
# Gather a list of all languages to support
self.language_list: T.List[str] = []
if language is None or force_use_global_compilers:
for_machine = T.cast('MachineChoice', kwargs.get('native', MachineChoice.HOST))
for_machine = kwargs.get('native', MachineChoice.HOST)
compilers = environment.coredata.compilers[for_machine]
candidates = ['c', 'cpp', 'fortran', 'objc', 'objcxx']
self.language_list += [x for x in candidates if x in compilers]
Expand Down Expand Up @@ -112,7 +113,7 @@ def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.
# Setup the trace parser
self.traceparser = CMakeTraceParser(self.cmakebin.version(), self._get_build_dir(), self.env)

cm_args = T.cast('T.List[str]', kwargs.get('cmake_args', []))
cm_args = kwargs.get('cmake_args', [])
cm_args = check_cmake_args(cm_args)
if CMakeDependency.class_cmakeinfo[self.for_machine] is None:
CMakeDependency.class_cmakeinfo[self.for_machine] = self._get_cmake_info(cm_args)
Expand All @@ -121,11 +122,11 @@ def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.
raise self._gen_exception('Unable to obtain CMake system information')
self.cmakeinfo = cmakeinfo

package_version = T.cast('str', kwargs.get('cmake_package_version', ''))
components = [(x, True) for x in T.cast('T.List[str]', kwargs.get('components', []))]
modules = [(x, True) for x in T.cast('T.List[str]', kwargs.get('modules', []))]
modules += [(x, False) for x in T.cast('T.List[str]', kwargs.get('optional_modules', []))]
cm_path = T.cast('T.List[str]', kwargs.get('cmake_module_path', []))
package_version = kwargs.get('cmake_package_version', '')
components = [(x, True) for x in kwargs.get('components', [])]
modules = [(x, True) for x in kwargs.get('modules', [])]
modules += [(x, False) for x in kwargs.get('optional_modules', [])]
cm_path = kwargs.get('cmake_module_path', [])
cm_path = [x if os.path.isabs(x) else os.path.join(environment.get_source_dir(), x) for x in cm_path]
if cm_path:
cm_args.append('-DCMAKE_MODULE_PATH=' + ';'.join(cm_path))
Expand Down Expand Up @@ -640,7 +641,7 @@ def __init__(self, name: T.Optional[str] = None, modules: T.Optional[T.List[str]
self.name = name
self.modules = modules

def __call__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> CMakeDependency:
def __call__(self, name: str, env: Environment, kwargs: DependencyKWs, language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> CMakeDependency:
if self.modules:
kwargs['modules'] = self.modules
return CMakeDependency(self.name or name, env, kwargs, language, force_use_global_compilers)
Expand Down
5 changes: 3 additions & 2 deletions mesonbuild/dependencies/coarrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .factory import factory_methods

if T.TYPE_CHECKING:
from .base import DependencyKWs
from . factory import DependencyGenerator
from ..environment import Environment
from ..mesonlib import MachineChoice
Expand All @@ -21,7 +22,7 @@
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE, DependencyMethods.SYSTEM})
def coarray_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
kwargs: DependencyKWs,
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
fcid = detect_compiler('coarray', env, for_machine, 'fortran').get_id()
candidates: T.List['DependencyGenerator'] = []
Expand Down Expand Up @@ -55,7 +56,7 @@ class CoarrayDependency(SystemDependency):
Coarrays may be thought of as a high-level language abstraction of
low-level MPI calls.
"""
def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None:
def __init__(self, environment: 'Environment', kwargs: DependencyKWs) -> None:
super().__init__('coarray', environment, kwargs, language='fortran')
kwargs['required'] = False
kwargs['silent'] = True
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/dependencies/configtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import typing as T

if T.TYPE_CHECKING:
from .base import DependencyKWs

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.configtool
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.configtool.
from ..environment import Environment
from ..interpreter.type_checking import PkgConfigDefineType

Expand All @@ -35,7 +36,7 @@ class ConfigToolDependency(ExternalDependency):
allow_default_for_cross = False
__strip_version = re.compile(r'^[0-9][0-9.]+')

def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, exclude_paths: T.Optional[T.List[str]] = None):
def __init__(self, name: str, environment: 'Environment', kwargs: DependencyKWs, language: T.Optional[str] = None, exclude_paths: T.Optional[T.List[str]] = None):
super().__init__(DependencyTypeName('config-tool'), environment, kwargs, language=language)
self.name = name
# You may want to overwrite the class version in some cases
Expand Down
7 changes: 4 additions & 3 deletions mesonbuild/dependencies/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


if T.TYPE_CHECKING:
from .base import DependencyKWs
from ..environment import Environment
from ..compilers import Compiler

Expand All @@ -26,7 +27,7 @@ class CudaDependency(SystemDependency):

supported_languages = ['cpp', 'c', 'cuda'] # see also _default_language

def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None:
def __init__(self, environment: 'Environment', kwargs: DependencyKWs) -> None:
compilers = environment.coredata.compilers[kwargs.get('native', mesonlib.MachineChoice.HOST)]
language = self._detect_language(compilers)
if language not in self.supported_languages:
Expand Down Expand Up @@ -276,8 +277,8 @@ def log_details(self) -> str:
def log_info(self) -> str:
return self.cuda_path if self.cuda_path else ''

def get_requested(self, kwargs: T.Dict[str, T.Any]) -> T.List[str]:
candidates = T.cast('T.List[str]', kwargs.get('modules', []))
def get_requested(self, kwargs: DependencyKWs) -> T.List[str]:
candidates = kwargs.get('modules', [])
for c in candidates:
if not isinstance(c, str):
raise DependencyException('CUDA module argument is not a string.')
Expand Down
9 changes: 5 additions & 4 deletions mesonbuild/dependencies/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .. import mlog

if T.TYPE_CHECKING:
from .base import DependencyKWs

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyKWs' may not be defined if module
mesonbuild.dependencies.base
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyKWs occurs after the cyclic
import
of mesonbuild.dependencies.detect.
from ..environment import Environment

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyFactory' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyFactory occurs after the cyclic
import
of mesonbuild.dependencies.detect.

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of WrappedFactoryFunc occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'WrappedFactoryFunc' may not be defined if module
mesonbuild.dependencies.factory
is importe

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module
mesonbuild.dependencies.factory
is imported before module
mesonbuild.dependencies.detect
, as the
definition
of DependencyGenerator occurs after the cyclic
import
of mesonbuild.dependencies.detect.
'DependencyGenerator' may not be defined if module [mesonbuild.depe
from .factory import DependencyFactory, WrappedFactoryFunc, DependencyGenerator

Expand All @@ -38,7 +39,7 @@ def __contains__(self, key: object) -> bool:
packages = DependencyPackages()
_packages_accept_language: T.Set[str] = set()

def get_dep_identifier(name: str, kwargs: T.Dict[str, T.Any]) -> 'TV_DepID':
def get_dep_identifier(name: str, kwargs: DependencyKWs) -> 'TV_DepID':
identifier: 'TV_DepID' = (('name', name), )
from ..interpreter.type_checking import DEPENDENCY_KWS

Expand Down Expand Up @@ -85,7 +86,7 @@ def get_dep_identifier(name: str, kwargs: T.Dict[str, T.Any]) -> 'TV_DepID':
'wxwidgets': 'WxWidgets',
}

def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str, object], candidates: T.Optional[T.List['DependencyGenerator']] = None) -> T.Union['ExternalDependency', NotFoundDependency]:
def find_external_dependency(name: str, env: 'Environment', kwargs: DependencyKWs, candidates: T.Optional[T.List['DependencyGenerator']] = None) -> T.Union['ExternalDependency', NotFoundDependency]:
assert name
required = kwargs.get('required', True)
lname = name.lower()
Expand All @@ -95,7 +96,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str,
# display the dependency name with correct casing
display_name = display_name_map.get(lname, lname)

for_machine = T.cast('MachineChoice', kwargs.get('native', MachineChoice.HOST))
for_machine = kwargs.get('native', MachineChoice.HOST)
type_text = PerMachine('Build-time', 'Run-time')[for_machine] + ' dependency'

# build a list of dependency methods to try
Expand Down Expand Up @@ -167,7 +168,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str,


def _build_external_dependency_list(name: str, env: 'Environment', for_machine: MachineChoice,
kwargs: T.Dict[str, T.Any]) -> T.List['DependencyGenerator']:
kwargs: DependencyKWs) -> T.List['DependencyGenerator']:
# Is there a specific dependency detector for this dependency?
lname = name.lower()
if lname in packages:
Expand Down
Loading

0 comments on commit 4fde72c

Please sign in to comment.