aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-28 11:58:03 -0700
committerGitHub <noreply@github.com>2021-08-28 11:58:03 -0700
commitf407ad5d28f24755a19bb95495141db0ad9fe740 (patch)
tree73f7eed2e85181d82058bfd19a2689756577c13e /mesonbuild/interpreterbase
parent64ea8dce7a26f06046c98bc7b3e30f06bf8ca98f (diff)
parentb4bc8464e69c353fc0792054ab4209d4e8b5a096 (diff)
downloadmeson-f407ad5d28f24755a19bb95495141db0ad9fe740.zip
meson-f407ad5d28f24755a19bb95495141db0ad9fe740.tar.gz
meson-f407ad5d28f24755a19bb95495141db0ad9fe740.tar.bz2
Merge pull request #9183 from dcbaker/submit/validate-default
Validate default values for KwargInfo
Diffstat (limited to 'mesonbuild/interpreterbase')
-rw-r--r--mesonbuild/interpreterbase/decorators.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py
index 2f59dd7..6aa4fca 100644
--- a/mesonbuild/interpreterbase/decorators.py
+++ b/mesonbuild/interpreterbase/decorators.py
@@ -467,8 +467,12 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]:
# conversion if necessary). This allows mutable types to
# be used safely as default values
if isinstance(info.types, ContainerTypeInfo):
+ assert isinstance(info.default, info.types.container), f'In function {name} default value of {info.name} is not a valid type, got {type(info.default)}, expected {info.types.container}[{info.types.contains}]'
+ for item in info.default:
+ assert isinstance(item, info.types.contains), f'In function {name} default value of {info.name}, container has invalid value of {item}, which is of type {type(item)}, but should be {info.types.contains}'
kwargs[info.name] = info.types.container(info.default)
else:
+ assert isinstance(info.default, info.types), f'In funcion {name} default value of {info.name} is not a valid type, got {type(info.default)} expected {info.types}'
kwargs[info.name] = info.default
if info.not_set_warning:
mlog.warning(info.not_set_warning)