diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-04 13:22:08 -0700 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-08-04 19:09:08 -0400 |
commit | 386b312fa9ec00af7594fc41e100a2bdab884d8f (patch) | |
tree | 1c1593e3e3b24b090e8a66e737a37a43b462f2a5 /mesonbuild | |
parent | f4a1da01455bbfdc7e34f8d96638e69f91d4a4bb (diff) | |
download | meson-386b312fa9ec00af7594fc41e100a2bdab884d8f.zip meson-386b312fa9ec00af7594fc41e100a2bdab884d8f.tar.gz meson-386b312fa9ec00af7594fc41e100a2bdab884d8f.tar.bz2 |
interpreterbase/decorators: fix typed_kwargs return type
Because of the convertor function we have no guarantee that what we're
getting is in fact a `Dict[str, TYPE_var]`, it might well be anything in
the values, so we need to do some casting and set the return type to
object. This works out fine in practice as our declared `TypeDict`
inputs in the actual function signatures will be used instead.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreterbase/decorators.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py index eabc6d8..1791deb 100644 --- a/mesonbuild/interpreterbase/decorators.py +++ b/mesonbuild/interpreterbase/decorators.py @@ -323,7 +323,7 @@ class KwargInfo(T.Generic[_T]): deprecated: T.Optional[str] = None, deprecated_values: T.Optional[T.Dict[str, str]] = None, validator: T.Optional[T.Callable[[_T], T.Optional[str]]] = None, - convertor: T.Optional[T.Callable[[_T], TYPE_var]] = None, + convertor: T.Optional[T.Callable[[_T], object]] = None, not_set_warning: T.Optional[str] = None): self.name = name self.types = types @@ -394,7 +394,9 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]: @wraps(f) def wrapper(*wrapped_args: T.Any, **wrapped_kwargs: T.Any) -> T.Any: - kwargs, subproject = get_callee_args(wrapped_args, want_subproject=True)[3:5] + _kwargs, subproject = get_callee_args(wrapped_args, want_subproject=True)[3:5] + # Cast here, as the convertor function may place something other than a TYPE_var in the kwargs + kwargs = T.cast(T.Dict[str, object], _kwargs) all_names = {t.name for t in types} unknowns = set(kwargs).difference(all_names) |