-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Context (Input, Language)
Input Format: JSON
Output Language: Python (Pydantic/Dataclasses)
Description
The existing Python Version Selector currently caps out at Python 3.7 (as shown in the UI). To support modern Python development and best practices, the selector needs to be updated to include at least Python 3.9 and Python 3.10.
Selecting these newer versions should automatically enable the modern type hint syntax, improving code readability and future-proofing the output.
Current Behaviour / Output
When generating Python code, the output uses legacy syntax that requires imports from the typing module (e.g., Optional[T], Union[A, B], List[T]).
Proposed Behaviour / Output
When a user selects Python 3.10, the generator should use the modern, built-in syntax (PEP 585 and PEP 604):
list[str]instead ofList[str](typing.List has been deprecated since Python 3.9)str | Noneinstead ofOptional[str]A | Binstead ofUnion[A, B]
Solution
Update the Python Version Selector list to include 3.9 and 3.10.
Implement the logic in the Python renderer to use the modern type hints (| for unions, built-in generics) when a version of 3.10 or higher is selected.
Alternatives
The only alternative is manually post-processing the code, which is cumbersome. This feature aligns with the existing tool design and provides the expected behavior for modern Python users.
Context
Modern Python projects universally prefer the built-in type syntax. Updating the version selector is the cleanest way to support these language features.