diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-12-02 10:35:11 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2021-12-06 20:06:14 -0500 |
commit | f5d961f1279e7e111657121849a78bd372502d79 (patch) | |
tree | 642835285e4582ad023d3111b63dab72bbefb119 /mesonbuild | |
parent | 51845a3a45647126866a898f8206fe581840ca92 (diff) | |
download | meson-f5d961f1279e7e111657121849a78bd372502d79.zip meson-f5d961f1279e7e111657121849a78bd372502d79.tar.gz meson-f5d961f1279e7e111657121849a78bd372502d79.tar.bz2 |
add message option to since_values and deprecated_values
This allows these two arguments to take a tuple of (version, message),
where the message will be passed to Feature*'s message parameter
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreterbase/decorators.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py index 1a203f8..8f4929f 100644 --- a/mesonbuild/interpreterbase/decorators.py +++ b/mesonbuild/interpreterbase/decorators.py @@ -388,10 +388,10 @@ class KwargInfo(T.Generic[_T]): default: T.Optional[_T] = None, since: T.Optional[str] = None, since_message: T.Optional[str] = None, - since_values: T.Optional[T.Dict[_T, str]] = None, + since_values: T.Optional[T.Dict[_T, T.Union[str, T.Tuple[str, str]]]] = None, deprecated: T.Optional[str] = None, deprecated_message: T.Optional[str] = None, - deprecated_values: T.Optional[T.Dict[_T, str]] = None, + deprecated_values: T.Optional[T.Dict[_T, T.Union[str, T.Tuple[str, str]]]] = None, validator: T.Optional[T.Callable[[T.Any], T.Optional[str]]] = None, convertor: T.Optional[T.Callable[[_T], object]] = None, not_set_warning: T.Optional[str] = None): @@ -417,10 +417,10 @@ class KwargInfo(T.Generic[_T]): default: T.Union[_T, None, _NULL_T] = _NULL, since: T.Union[str, None, _NULL_T] = _NULL, since_message: T.Union[str, None, _NULL_T] = _NULL, - since_values: T.Union[T.Dict[_T, str], None, _NULL_T] = _NULL, + since_values: T.Union[T.Dict[_T, T.Union[str, T.Tuple[str, str]]], None, _NULL_T] = _NULL, deprecated: T.Union[str, None, _NULL_T] = _NULL, deprecated_message: T.Union[str, None, _NULL_T] = _NULL, - deprecated_values: T.Union[T.Dict[_T, str], None, _NULL_T] = _NULL, + deprecated_values: T.Union[T.Dict[_T, T.Union[str, T.Tuple[str, str]]], None, _NULL_T] = _NULL, validator: T.Union[T.Callable[[_T], T.Optional[str]], None, _NULL_T] = _NULL, convertor: T.Union[T.Callable[[_T], TYPE_var], None, _NULL_T] = _NULL) -> 'KwargInfo': """Create a shallow copy of this KwargInfo, with modifications. @@ -535,6 +535,7 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]: raise InvalidArguments(f'{name} keyword argument "{info.name}" {msg}') warn: bool + msg: T.Optional[str] if info.deprecated_values is not None: for n, version in info.deprecated_values.items(): if isinstance(value, (dict, list)): @@ -543,7 +544,11 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]: warn = n == value if warn: - FeatureDeprecated.single_use(f'"{name}" keyword argument "{info.name}" value "{n}"', version, subproject, location=node) + if isinstance(version, tuple): + version, msg = version + else: + msg = None + FeatureDeprecated.single_use(f'"{name}" keyword argument "{info.name}" value "{n}"', version, subproject, msg, location=node) if info.since_values is not None: for n, version in info.since_values.items(): @@ -553,7 +558,11 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]: warn = n == value if warn: - FeatureNew.single_use(f'"{name}" keyword argument "{info.name}" value "{n}"', version, subproject, location=node) + if isinstance(version, tuple): + version, msg = version + else: + msg = None + FeatureNew.single_use(f'"{name}" keyword argument "{info.name}" value "{n}"', version, subproject, msg, location=node) elif info.required: raise InvalidArguments(f'{name} is missing required keyword argument "{info.name}"') |