Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Type annotation
None
now correctly supported with value-check …
…and `"null"` (#1429) Resolves #1423 - `"null"` is helpful if you build requests in JS have `null` values - If a annotation is missing, it's `param.empty` but this is difference to an explicit set `None` type annotation and needs to processed separately as `empty` - The other _"simple types"_ do a type-cast and would raise a `ValueError` in case of invalid data, but `None` was always taken, regardless of the value?! Here some examples of definition which had some issues before and are now working as expected: ```py @Exposed def my_method( self, *, test0: None | db.Key | str = None, test1: None = None, test2: None | str = None, test3: str | None = None, test4=None, test5: int = None, ): ``` 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 only `None`, `"None"` or `"null"`. But `test4` has no type annotation and accepts any value as-is. Providing `"None"` for `test2` would result into `None`, while `"None"` for `test3` 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 always `None`.
- Loading branch information