modules/cmake: use typed_pos_args for subproject.get_variable

pull/13739/head
Dylan Baker 3 months ago
parent e2508053a2
commit 2ce15a6906
  1. 11
      mesonbuild/interpreter/interpreterobjects.py
  2. 8
      mesonbuild/modules/cmake.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

@ -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'})

Loading…
Cancel
Save