aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-12-01 15:45:48 -0800
committerEli Schwartz <eschwartz93@gmail.com>2021-12-06 20:06:14 -0500
commit82136da933f0859edd6cf168a129ede706e9e055 (patch)
treee37ead97fcbf2351941bb311dddee5487453b449
parent7191b6dab2b310adb93238bac804008e9c9757b8 (diff)
downloadmeson-82136da933f0859edd6cf168a129ede706e9e055.zip
meson-82136da933f0859edd6cf168a129ede706e9e055.tar.gz
meson-82136da933f0859edd6cf168a129ede706e9e055.tar.bz2
interpreterbase/decorators: Fix types of deprecated_values and since_values
Which shouldn't be Dict[str, str], they should be Dict[_T, str], as nay value that can be passed to types is valid here.
-rw-r--r--mesonbuild/interpreterbase/decorators.py5
-rw-r--r--unittests/internaltests.py5
2 files changed, 8 insertions, 2 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py
index 8c849e9..9434ab7 100644
--- a/mesonbuild/interpreterbase/decorators.py
+++ b/mesonbuild/interpreterbase/decorators.py
@@ -372,7 +372,8 @@ class KwargInfo(T.Generic[_T]):
string, but the implementation using an Enum. This should not do
validation, just conversion.
:param deprecated_values: a dictionary mapping a value to the version of
- meson it was deprecated in.
+ meson it was deprecated in. The Value may be any valid value for this
+ argument.
:param since_values: a dictionary mapping a value to the version of meson it was
added in.
:param not_set_warning: A warning message that is logged if the kwarg is not
@@ -385,7 +386,7 @@ class KwargInfo(T.Generic[_T]):
since: T.Optional[str] = None,
since_values: T.Optional[T.Dict[str, str]] = None,
deprecated: T.Optional[str] = None,
- deprecated_values: T.Optional[T.Dict[str, str]] = None,
+ deprecated_values: T.Optional[T.Dict[_T, str]] = 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):
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index c4fd0a6..4135655 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -1378,6 +1378,7 @@ class InternalTests(unittest.TestCase):
'testfunc',
KwargInfo('input', ContainerTypeInfo(list, str), listify=True, default=[], deprecated_values={'foo': '0.9'}, since_values={'bar': '1.1'}),
KwargInfo('output', ContainerTypeInfo(dict, str), default={}, deprecated_values={'foo': '0.9'}, since_values={'bar': '1.1'}),
+ KwargInfo('install_dir', (bool, str, NoneType), deprecated_values={False: '0.9'}),
KwargInfo(
'mode',
(str, type(None)),
@@ -1403,6 +1404,10 @@ class InternalTests(unittest.TestCase):
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "output" value "foo".*""")
with mock.patch('sys.stdout', io.StringIO()) as out:
+ _(None, mock.Mock(subproject=''), [], {'install_dir': False})
+ self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "install_dir" value "False".*""")
+
+ with mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'output': {'bar': 'b'}})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*introduced in '1.1': "testfunc" keyword argument "output" value "bar".*""")