-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error messages for typed_kwarg type mismatches in containers #9599
Improve error messages for typed_kwarg type mismatches in containers #9599
Conversation
And you even have a free fix for run_single_test being useless for tests that invert the error code and test that certain things should produce errors! That one's been bugging me for a while... |
Codecov Report
@@ Coverage Diff @@
## master #9599 +/- ##
=======================================
Coverage 67.41% 67.41%
=======================================
Files 402 402
Lines 85478 85498 +20
Branches 17620 17632 +12
=======================================
+ Hits 57625 57640 +15
- Misses 23246 23249 +3
- Partials 4607 4609 +2
Continue to review full report at Codecov.
|
The inner closure of the typed_kwargs function is already complicated enough without defining closures in the middle of a loop. Let's just pass the types_tuple as an argument to both avoid redefining the function over and over, and also make the whole thing easier to read.
bba07e2
to
28c422e
Compare
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.
Python uses this syntax now, as does typescript and other languages
We don't want to get something like "expected array[str], but got array[int | int]", we really want `arrayp[int]`.
28c422e
to
d412f0a
Compare
Currently if an argument is
T.List[str]
, but you passT.List[int]
, then you get a message likeshould ahve been List[str], but was list
. That's not helpful.This series makes a few small tweaks to make this all much more useful. First, it replaces that wit "but was" message with a more useful
but was list[int]
. Then it replaces "list" with "array", since meson has array's, not lists. Finally, it moves to the more standard|
as a representation for union types, iearray[int | str]
, which both python and typescript use, so it should be clearer.