Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 695 - Type Parameter Syntax #1004

Merged
merged 1 commit into from
Aug 28, 2023
Merged

PEP 695 - Type Parameter Syntax #1004

merged 1 commit into from
Aug 28, 2023

Commits on Aug 28, 2023

  1. PEP 695 - Type Parameter Syntax

    This PR adds support for parsing and representing Type Parameters and Type Aliases as specified by PEP 695. What's missing are the scope rules, to be implemented in a future PR.
    
    Notable (user visible) changes:
    
    - new `TypeAlias` CST node, which is a `SmallStatement`
    - new CST nodes to represent TypeVarLikes: `TypeVar`, `TypeVarTuple`, `ParamSpec`
    - new helper CST nodes:  `TypeParameters` to serve as a container for multiple TypeVarLikes, and `TypeParam` which is a single item in a `TypeParameters` (owning the separating comma)
    - extended `FunctionDef` and `ClassDef` with an optional `type_parameters` field, as well as `whitespace_after_type_parameters` to own the extra whitespace between type parameters and the following token
      - these new fields are added after all others to avoid breaking callers passing in fields as positional arguments
    - in `FunctionDef` and `ClassDef`, `whitespace_after_name` now owns the whitespace before the type parameters if they exist
    zsol committed Aug 28, 2023
    Configuration menu
    Copy the full SHA
    87461db View commit details
    Browse the repository at this point in the history