summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-01-10 13:40:06 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-10-15 10:21:46 -0700
commitede3f49903b5b797dfb92e0fd341921a611a97eb (patch)
tree610799b06165ee96b377c8495bbe870a136ce3fa
parent63eb585f0c6054dc8a4d0f9302643e6d49c3f0a7 (diff)
downloadmeson-ede3f49903b5b797dfb92e0fd341921a611a97eb.tar.gz
Revert "typed_kwargs: Remove feature_validator as it's not currently used"
This reverts commit 93c11f249495c4af4a88206cebefef3ecf0f3228. We're going to use it again in the next commit
-rw-r--r--mesonbuild/interpreterbase/decorators.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py
index a847689b7..ea1d30605 100644
--- a/mesonbuild/interpreterbase/decorators.py
+++ b/mesonbuild/interpreterbase/decorators.py
@@ -352,6 +352,7 @@ class KwargInfo(T.Generic[_T]):
added in.
:param not_set_warning: A warning message that is logged if the kwarg is not
set by the user.
+ :param feature_validator: A callable returning an iterable of FeatureNew | FeatureDeprecated objects.
"""
def __init__(self, name: str,
types: T.Union[T.Type[_T], T.Tuple[T.Union[T.Type[_T], ContainerTypeInfo], ...], ContainerTypeInfo],
@@ -363,6 +364,7 @@ class KwargInfo(T.Generic[_T]):
deprecated: T.Optional[str] = None,
deprecated_message: T.Optional[str] = None,
deprecated_values: T.Optional[T.Dict[T.Union[_T, ContainerTypeInfo, type], T.Union[str, T.Tuple[str, str]]]] = None,
+ feature_validator: T.Optional[T.Callable[[_T], T.Iterable[FeatureCheckBase]]] = 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):
@@ -374,6 +376,7 @@ class KwargInfo(T.Generic[_T]):
self.since = since
self.since_message = since_message
self.since_values = since_values
+ self.feature_validator = feature_validator
self.deprecated = deprecated
self.deprecated_message = deprecated_message
self.deprecated_values = deprecated_values
@@ -392,6 +395,7 @@ class KwargInfo(T.Generic[_T]):
deprecated: T.Union[str, None, _NULL_T] = _NULL,
deprecated_message: T.Union[str, None, _NULL_T] = _NULL,
deprecated_values: T.Union[T.Dict[T.Union[_T, ContainerTypeInfo, type], T.Union[str, T.Tuple[str, str]]], None, _NULL_T] = _NULL,
+ feature_validator: T.Union[T.Callable[[_T], T.Iterable[FeatureCheckBase]], None, _NULL_T] = _NULL,
validator: T.Union[T.Callable[[_T], T.Optional[str]], None, _NULL_T] = _NULL,
convertor: T.Union[T.Callable[[_T], object], None, _NULL_T] = _NULL) -> 'KwargInfo':
"""Create a shallow copy of this KwargInfo, with modifications.
@@ -417,6 +421,7 @@ class KwargInfo(T.Generic[_T]):
deprecated=deprecated if not isinstance(deprecated, _NULL_T) else self.deprecated,
deprecated_message=deprecated_message if not isinstance(deprecated_message, _NULL_T) else self.deprecated_message,
deprecated_values=deprecated_values if not isinstance(deprecated_values, _NULL_T) else self.deprecated_values,
+ feature_validator=feature_validator if not isinstance(feature_validator, _NULL_T) else self.feature_validator,
validator=validator if not isinstance(validator, _NULL_T) else self.validator,
convertor=convertor if not isinstance(convertor, _NULL_T) else self.convertor,
)
@@ -532,6 +537,10 @@ def typed_kwargs(name: str, *types: KwargInfo, allow_unknown: bool = False) -> T
if msg is not None:
raise InvalidArguments(f'{name} keyword argument "{info.name}" {msg}')
+ if info.feature_validator is not None:
+ for each in info.feature_validator(value):
+ each.use(subproject, node)
+
if info.deprecated_values is not None:
emit_feature_change(info.deprecated_values, FeatureDeprecated)