fix: request type annotation None
is now correctly supported and value-check and supports "null"
#1429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1423
"null"
is helpful if you build requests in JS havenull
valuesparam.empty
but this is difference to an explicit setNone
type annotation and needs to processed separately asempty
ValueError
in case of invalid data, butNone
was always taken, regardless of the value?!Here some examples of definition which had some issues before and are now working as expected:
Of course
test1: None = None
is a little bit impractical, but since it's a valid syntax it should also work in this way and accept onlyNone
,"None"
or"null"
. Buttest4
has no type annotation and accepts any value as-is.Providing
"None"
fortest2
would result intoNone
, while"None"
fortest3
would result into"None"
(due to the order).However, my initially problem parameter
test0: None | db.Key | str = None,
is now working as expected: I can provide explicit"None"
or"null"
and it's no longer alwaysNone
.