Skip to content

[FEATURE]: Support newer typing features introduced in Python 3.9 and 3.10 (PEP 585 and PEP 604 syntax) #2848

@5j9

Description

@5j9

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):

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions