Skip to content

PEP 695 – Type Parameter Syntax #82

Closed
@tjf801

Description

@tjf801

Feature

Seeing as how Python 3.12 is now in beta, I feel like RustPython should also work on being able to parse the new syntax introduced in PEP 695, which makes it much easier to type-hint generic functions and types in the language. I ran into this while trying to start writing a custom type checker, and wanted to use rustpython_ast to parse Python 3.12 code that uses this new syntax. Some examples include:

def identity[T](x: T) -> T:
    return x

type Point = tuple[float, float]

type MappingOrSequence[T] = Mapping[int, T] | Sequence[T]

class Container[T](Sequence[T]): ...

Python Documentation or reference to CPython source code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions