diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2024-08-27 13:06:36 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2024-10-01 08:26:40 -0700 |
commit | 2ce15a690601101826cad501a9b9e24a0c774252 (patch) | |
tree | 86f5be553783d38feb5ae424db20f75a1d3b4b62 | |
parent | e2508053a264a521671fa01c234e3db979de2a70 (diff) | |
download | meson-2ce15a690601101826cad501a9b9e24a0c774252.zip meson-2ce15a690601101826cad501a9b9e24a0c774252.tar.gz meson-2ce15a690601101826cad501a9b9e24a0c774252.tar.bz2 |
modules/cmake: use typed_pos_args for subproject.get_variable
-rw-r--r-- | mesonbuild/interpreter/interpreterobjects.py | 11 | ||||
-rw-r--r-- | mesonbuild/modules/cmake.py | 8 |
2 files changed, 11 insertions, 8 deletions
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py index 4ff53d3..a919102 100644 --- a/mesonbuild/interpreter/interpreterobjects.py +++ b/mesonbuild/interpreter/interpreterobjects.py @@ -843,11 +843,8 @@ class SubprojectHolder(MesonInterpreterObject): def found(self) -> bool: return not isinstance(self.held_object, NullSubprojectInterpreter) - @noKwargs - @typed_pos_args('subproject.get_variable', str, optargs=[object]) - @noArgsFlattening @unholder_return - def get_variable_method(self, args: T.Tuple[str, T.Optional[HoldableObject]], kwargs: TYPE_kwargs) -> T.Union[TYPE_var, InterpreterObject]: + def get_variable(self, args: T.Tuple[str, T.Optional[str]], kwargs: TYPE_kwargs) -> T.Union[TYPE_var, InterpreterObject]: if isinstance(self.held_object, NullSubprojectInterpreter): # == not self.found() raise InterpreterException(f'Subproject "{self.subdir}" disabled can\'t get_variable on it.') varname, fallback = args @@ -858,6 +855,12 @@ class SubprojectHolder(MesonInterpreterObject): return self.held_object._holderify(fallback) raise InvalidArguments(f'Requested variable "{varname}" not found.') + @noKwargs + @typed_pos_args('subproject.get_variable', str, optargs=[object]) + @noArgsFlattening + def get_variable_method(self, args: T.Tuple[str, T.Optional[str]], kwargs: TYPE_kwargs) -> T.Union[TYPE_var, InterpreterObject]: + return self.get_variable(args, kwargs) + class ModuleObjectHolder(ObjectHolder[ModuleObject]): def method_call(self, method_name: str, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> TYPE_var: modobj = self.held_object diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index 4fda7b3..78a1a0c 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -39,7 +39,7 @@ if T.TYPE_CHECKING: from ..cmake import SingleTargetOptions from ..environment import Environment from ..interpreter import Interpreter, kwargs - from ..interpreterbase import TYPE_kwargs, TYPE_var + from ..interpreterbase import TYPE_kwargs, TYPE_var, InterpreterObject class WriteBasicPackageVersionFile(TypedDict): @@ -126,9 +126,9 @@ class CMakeSubproject(ModuleObject): return res @noKwargs - @stringArgs - def get_variable(self, state: ModuleState, args: T.List[str], kwargs: TYPE_kwargs) -> TYPE_var: - return self.subp.get_variable_method(args, kwargs) + @typed_pos_args('cmake.subproject.get_variable', str, optargs=[str]) + def get_variable(self, state: ModuleState, args: T.Tuple[str, T.Optional[str]], kwargs: TYPE_kwargs) -> T.Union[TYPE_var, InterpreterObject]: + return self.subp.get_variable(args, kwargs) @FeatureNewKwargs('dependency', '0.56.0', ['include_type']) @permittedKwargs({'include_type'}) |