You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix multiple issues with converting type hints to JSON Schema
The main issue: newish syntax for unions with `|` supported by Python 3.10 are of [type](https://docs.python.org/3.10/library/types.html#types.UnionType) `types.UnionType`, and didn't match `type(Union)`. There's a very recently [completed issue on CPython](python/cpython#105499) that will unify both (apparently for 3.14). See also this [MyPy warning](https://mypy.readthedocs.io/en/stable/runtime_troubles.html#future-annotations-import-pep-563) about evaluating type hints.
Other issues:
- Only unions of two values were properly handled for optional values;
- Unions with more than two values and an optional one would only parse one of the values, dropping the others;
- Some code lines were never true (like `isinstance(arg_json_schema["type"], list)`);
The code is now simplified while handling new type annotation syntax and null/optional values.
0 commit comments