aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/compiler.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-23 14:07:57 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-08-27 14:49:23 -0700
commitaa895b383cc726800d7d6e7e540db96dfe9df1f2 (patch)
tree5cc2e66859f342b4afd6372bca4331ad5fae3faa /mesonbuild/interpreter/compiler.py
parent4523e9d288d3a97e54d1e971ab9c022616b710e2 (diff)
downloadmeson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.zip
meson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.tar.gz
meson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.tar.bz2
interpreter: Add a helper for checking constrained inputs
This is quite valuable for enum-like inputs, where only a certain set of values is allowed.
Diffstat (limited to 'mesonbuild/interpreter/compiler.py')
-rw-r--r--mesonbuild/interpreter/compiler.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py
index 7491fce..53c3ce0 100644
--- a/mesonbuild/interpreter/compiler.py
+++ b/mesonbuild/interpreter/compiler.py
@@ -17,7 +17,7 @@ from ..interpreterbase import (ObjectHolder, noPosargs, noKwargs,
InterpreterException)
from ..interpreterbase.decorators import ContainerTypeInfo, typed_kwargs, KwargInfo, typed_pos_args
from .interpreterobjects import (extract_required_kwarg, extract_search_dirs)
-from .type_checking import REQUIRED_KW
+from .type_checking import REQUIRED_KW, in_set_validator
if T.TYPE_CHECKING:
from ..interpreter import Interpreter
@@ -638,7 +638,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
@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)
+ validator=in_set_validator({'warn', 'require', 'off'})),
)
def get_supported_arguments_method(self, args: T.Tuple[T.List[str]], kwargs: 'GetSupportedArgumentKw') -> T.List[str]:
supported_args: T.List[str] = []