Commit Graph

24 Commits

Author SHA1 Message Date
Dylan Baker f5d961f127 add message option to since_values and deprecated_values
This allows these two arguments to take a tuple of (version, message),
where the message will be passed to Feature*'s message parameter
2021-12-06 20:06:14 -05:00
Dylan Baker 51845a3a45 unittests/internal: use more subTest 2021-12-06 20:06:14 -05:00
Dylan Baker 930cbdb86d Add deprecated_message and since_message to KwargInfo
For passing an extra message to Feature*

This allows providing a more detailed message.
2021-12-06 20:06:14 -05:00
Dylan Baker b8ba493044 unittests/internal: use mock and subTest
This just makes things a little cleaner, and allows more accurate error
reporting.
2021-12-06 20:06:14 -05:00
Dylan Baker 82136da933 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.
2021-12-06 20:06:14 -05:00
Jussi Pakkanen 11e26a0fa9
Merge pull request #9599 from dcbaker/submit/typed_kwargs-message-improvements
Improve error messages for typed_kwarg type mismatches in containers
2021-11-27 22:33:15 +02:00
Dylan Baker bfa0c61877 tests: add a test for OptionKey.from_string 2021-11-25 18:14:06 +02:00
Dylan Baker d412f0aff5 unittests: cover cases here two of the same wrong type are provided
We don't want to get something like "expected array[str], but got
array[int | int]", we really want `arrayp[int]`.
2021-11-22 12:27:17 -08:00
Dylan Baker 762c504612 typed_kwargs: use | for type unions, not ,
Python uses this syntax now, as does typescript and other languages
2021-11-22 12:24:33 -08:00
Dylan Baker ecc47d67a9 typed_kwargs: provide better error messages for wrong container types
Currently, if you pass a `[]string`, but the argument expects
`[]number`, then you get a message like `expected list[str] but got
list`. That isn't helpful. With this patch arrays and dictionaries will
both print messages with the types provided.
2021-11-22 12:24:14 -08:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Xavier Claessens 709d151eb9 typed_kwargs: Fix when ContainerTypeInfo is used in a tuple
info.types could be a tuple like (str, ContainerTypeInfo()). That means
we have to check types one by one and only print error if none of them
matched.

Also fix the case when default value is None for a container type, it
should leave the value to None to be able to distinguish between unset
and empty list.
2021-10-09 18:13:34 -04:00
Eli Schwartz e8a85fa8a2
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only"

and committing the results. Although this has been performed in the
past, newer versions of pyupgrade can automatically catch more
opportunities, notably list comprehensions can use generators instead,
in the following cases:
- unpacking into function arguments as function(*generator)
- unpacking into assignments of the form x, y = generator
- as the argument to some builtin functions such as min/max/sorted

Also catch a few creeping cases of new code added using older styles.
2021-10-04 16:29:30 -04:00
Xavier Claessens ca866bcfc7 coredata: 0.59.1 -> 0.59.99 is a major version difference
Remove test_minor_version_does_not_reconfigure_wipe() because when run
during dev cycle that test reconfigure with .99 -> .100 which is
considered a major version change now. It is covered by a more efficient
internal test now anyway.

While at it, remove no-op `with Path(self.builddir):` statement, the
intention was clearly to set workdir.

Fixes: #9260
2021-09-21 18:09:12 +02:00
Dylan Baker bd691b847c interpreter: use python dunders instead of lock for unpicklability
This simplifies things for us, as we don't have to have threading
imported for no other reason, and we can remove the
`an_unpicklable_object` from the Interpreter and mesonlib, since there
was only one user of this.
2021-08-31 16:59:37 -07:00
Dylan Baker 042016a555 unittests: add a test to Interpreter is unpicklable
We want this, so let's test it.
2021-08-31 16:59:37 -07:00
Dylan Baker f073c3cfe1 environment: correctly handle cpu value aarch64_be
Fixes #9191
2021-08-30 10:41:12 -07:00
Dylan Baker 78f8a286d0 environment: add ppc -> ppc64 for aix to detect_cpu
This seems like an oversight, that we'd replace ppc with ppc64 on AIX
for the cpu_family, but not for the specific cpu.
2021-08-30 10:38:47 -07:00
Dylan Baker b8cdae7003 unittests: add tests for detect_cpu
Same thing, but for the more specific cases
2021-08-30 10:37:41 -07:00
Dylan Baker 84fff3521a unittests: Add a test case for detect_cpu_family
This should help prevent regressions.
2021-08-30 10:33:28 -07:00
Dylan Baker 11fbaf29d8 interpreter: fix cases of `KwargInfo(..., T, default=None)`
The correct way to mark these is `KwargInfo(..., (T, type(None)))`.
There's also a few cases of `(T, None)` which is invalid, as `None`
isn't a type
2021-08-27 14:54:29 -07:00
Dylan Baker aa895b383c 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.
2021-08-27 14:49:23 -07:00
Dylan Baker a450f8c6bc interenaltests: Add some version strings with ansi escapes in them
AS we've run into a few programs using ansi escapes in their version
outputs, we'd like to test them as well.
2021-07-30 10:19:28 -07:00
Xavier Claessens 7eb4c23156 Split run_unittests.py file 2021-07-26 15:19:13 -04:00