diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-01-11 11:23:52 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-01-20 00:18:42 -0500 |
commit | 43a24047076f24f371f2cb8f334da43f8ae6059f (patch) | |
tree | 8a1f3ca0146276e0f86c5e4831c2dc0789483e1b /mesonbuild | |
parent | f5eaebb4b46a7e87e6c91a81da93ec28d4362546 (diff) | |
download | meson-43a24047076f24f371f2cb8f334da43f8ae6059f.zip meson-43a24047076f24f371f2cb8f334da43f8ae6059f.tar.gz meson-43a24047076f24f371f2cb8f334da43f8ae6059f.tar.bz2 |
Deprecate passing strings to non-string options
Currently Meson allow the following (Muon does not):
```meson
option('foo', type : 'boolean', value : 'true')
option('bar', type : 'integer', value : '42')
```
This is possibly a holdover from very old code, but it's a bad idea and
we should stop doing it. This deprecation is the first stop on that
journey.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/optinterpreter.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index de7ba04..9251df8 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -20,7 +20,7 @@ from . import coredata from . import mesonlib from . import mparser from . import mlog -from .interpreterbase import FeatureNew, typed_pos_args, typed_kwargs, ContainerTypeInfo, KwargInfo +from .interpreterbase import FeatureNew, typed_pos_args, typed_kwargs, ContainerTypeInfo, KwargInfo, FeatureDeprecated from .interpreter.type_checking import NoneType, in_set_validator if T.TYPE_CHECKING: from .interpreterbase import TYPE_var, TYPE_kwargs @@ -221,6 +221,7 @@ class OptionInterpreter: (bool, str), default=True, validator=lambda x: None if isinstance(x, bool) or x in {'true', 'false'} else 'boolean options must have boolean values', + deprecated_values={'true': ('1.1.0', 'use a boolean, not a string'), 'false': ('1.1.0', 'use a boolean, not a string')}, ), ) def boolean_parser(self, description: str, yield_: bool, kwargs: BooleanArgs) -> coredata.UserOption: @@ -244,6 +245,7 @@ class OptionInterpreter: 'value', (int, str), default=True, + feature_validator=lambda x: [FeatureDeprecated('number values as strings', '1.1.0', 'use a raw number instead')] if isinstance(x, str) else [], convertor=int, ), KwargInfo('min', (int, NoneType)), |