aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/factory.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-08-29 20:06:11 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-09-12 19:16:59 -0400
commitb821a0351136b3b3872e2ba9da8f7c67c4275449 (patch)
tree5ce60dae3f3e71fdf96710ba1f11cdcd91a7d1f4 /mesonbuild/dependencies/factory.py
parent7972c49bda5c2fcd6d647f45f5a5fa250f68f4b6 (diff)
downloadmeson-b821a0351136b3b3872e2ba9da8f7c67c4275449.zip
meson-b821a0351136b3b3872e2ba9da8f7c67c4275449.tar.gz
meson-b821a0351136b3b3872e2ba9da8f7c67c4275449.tar.bz2
dependencies: use better internal representation of factory methods
functools.partial preserves information about how the method was created, lambdas do not. Also, we just want to freeze the first argument and forward the rest anyway. This also lets us get rid of a mypy error that was being ignored.
Diffstat (limited to 'mesonbuild/dependencies/factory.py')
-rw-r--r--mesonbuild/dependencies/factory.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mesonbuild/dependencies/factory.py b/mesonbuild/dependencies/factory.py
index b26bbd6..d50ce0f 100644
--- a/mesonbuild/dependencies/factory.py
+++ b/mesonbuild/dependencies/factory.py
@@ -100,15 +100,15 @@ class DependencyFactory:
] = {
# Just attach the correct name right now, either the generic name
# or the method specific name.
- DependencyMethods.EXTRAFRAMEWORK: lambda env, kwargs: framework_class(framework_name or name, env, kwargs),
- DependencyMethods.PKGCONFIG: lambda env, kwargs: pkgconfig_class(pkgconfig_name or name, env, kwargs),
- DependencyMethods.CMAKE: lambda env, kwargs: cmake_class(cmake_name or name, env, kwargs),
- DependencyMethods.SYSTEM: lambda env, kwargs: system_class(name, env, kwargs),
- DependencyMethods.BUILTIN: lambda env, kwargs: builtin_class(name, env, kwargs),
+ DependencyMethods.EXTRAFRAMEWORK: functools.partial(framework_class, framework_name or name),
+ DependencyMethods.PKGCONFIG: functools.partial(pkgconfig_class, pkgconfig_name or name),
+ DependencyMethods.CMAKE: functools.partial(cmake_class, cmake_name or name),
+ DependencyMethods.SYSTEM: functools.partial(system_class, name),
+ DependencyMethods.BUILTIN: functools.partial(builtin_class, name),
DependencyMethods.CONFIG_TOOL: None,
}
if configtool_class is not None:
- self.classes[DependencyMethods.CONFIG_TOOL] = lambda env, kwargs: configtool_class(name, env, kwargs)
+ self.classes[DependencyMethods.CONFIG_TOOL] = functools.partial(configtool_class, name)
@staticmethod
def _process_method(method: DependencyMethods, env: 'Environment', for_machine: MachineChoice) -> bool: