From f5c8f8b659f53f228fe3bf5f226de565b40bc172 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 13 Feb 2023 00:39:46 -0500 Subject: [PATCH] python module: fix a few mypy issues Of particular note: We technically cannot pass a NotFoundDependency out of a factory lookup, because it doesn't support External interfaces. --- mesonbuild/modules/python.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 0c3d6a1f2..a5db0194c 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -26,7 +26,8 @@ from .. import mesonlib from .. import mlog from ..coredata import UserFeatureOption from ..build import known_shmod_kwargs -from ..dependencies import DependencyMethods, PkgConfigDependency, NotFoundDependency, SystemDependency, ExtraFrameworkDependency +from ..dependencies import (DependencyMethods, PkgConfigDependency, NotFoundDependency, SystemDependency, ExtraFrameworkDependency, + DependencyTypeName, ExternalDependency) from ..dependencies.base import process_method_kw from ..dependencies.detect import get_dep_identifier from ..environment import detect_cpu_family @@ -46,7 +47,7 @@ if T.TYPE_CHECKING: from . import ModuleState from ..build import SharedModule, Data - from ..dependencies import ExternalDependency, Dependency + from ..dependencies import Dependency from ..dependencies.factory import DependencyGenerator from ..environment import Environment from ..interpreter import Interpreter @@ -298,7 +299,9 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice', installation: 'PythonInstallation') -> 'ExternalDependency': if not pkg_libdir: # there is no LIBPC, so we can't search in it - return NotFoundDependency('python', env) + empty = ExternalDependency(DependencyTypeName('pkgconfig'), env, {}) + empty.name = 'python' + return empty old_pkg_libdir = os.environ.pop('PKG_CONFIG_LIBDIR', None) old_pkg_path = os.environ.pop('PKG_CONFIG_PATH', None) @@ -306,7 +309,7 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice', try: return PythonPkgConfigDependency(name, env, kwargs, installation, True) finally: - def set_env(name, value): + def set_env(name: str, value: str) -> None: if value is not None: os.environ[name] = value elif name in os.environ: @@ -428,6 +431,7 @@ class PythonExternalProgram(ExternalProgram): 'sysconfig_paths': {}, 'paths': {}, 'platform': 'sentinal', + 'suffix': 'sentinel', 'variables': {}, 'version': '0.0', }