diff options
author | Laurin-Luis Lehning <65224843+e820@users.noreply.github.com> | 2021-06-22 07:59:08 +0200 |
---|---|---|
committer | Laurin-Luis Lehning <65224843+e820@users.noreply.github.com> | 2021-06-22 07:59:08 +0200 |
commit | 281f5abee342b7b53ea50dd8280df4a410382f75 (patch) | |
tree | c81a4062e201805af898672afe7b193e21df9c2f | |
parent | d5ed8f61a5cd7a5d384ccd59abc219154a00d42c (diff) | |
download | meson-281f5abee342b7b53ea50dd8280df4a410382f75.zip meson-281f5abee342b7b53ea50dd8280df4a410382f75.tar.gz meson-281f5abee342b7b53ea50dd8280df4a410382f75.tar.bz2 |
interpreter: Replace manual kwarg validation in compiler.get_supported_arguments with @typed_kwargs
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index 9a6beeb..b1eef2f 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -1,5 +1,6 @@ import functools -from mesonbuild.interpreterbase.decorators import typed_kwargs, KwargInfo + +from ..interpreterbase.decorators import typed_kwargs, KwargInfo from .interpreterobjects import (extract_required_kwarg, extract_search_dirs) @@ -685,16 +686,16 @@ class CompilerHolder(ObjectHolder['Compiler']): return result @FeatureNew('compiler.get_supported_arguments', '0.43.0') - @FeatureNewKwargs('compiler.get_supported_arguments', '0.59.0', ['checked']) - @typed_kwargs('compiler.get_supported_arguments', KwargInfo('checked', str, default='off')) + @typed_kwargs( + 'compiler.get_supported_arguments', + KwargInfo('checked', str, default='off', since='0.59.0', + validator=lambda s: 'must be one of "warn", "require" or "off"' if s not in ['warn', 'require', 'off'] else None) + ) def get_supported_arguments_method(self, args: T.Sequence[str], kwargs: T.Dict[str, T.Any]): args = mesonlib.stringlistify(args) supported_args = [] checked = kwargs.pop('checked') - if checked not in ['warn', 'require', 'off']: - raise mesonlib.MesonException('"checked" kwarg must be one of "warn", "require" or "off"') - for arg in args: if not self.has_argument_method(arg, kwargs): msg = f'Compiler for {self.compiler.get_display_language()} does not support "{arg}"' |