Skip to content

parso can't parse PEP 695: Type Parameter Syntax #221

@heavenshell

Description

@heavenshell

Hi, first of all thank you for creating awesome library.
I'm useing parso in my library.

Python3.12 has big change at grammer.
https://docs.python.org/3/whatsnew/3.12.html#whatsnew312-pep695

parso does not support PEP 695: Type Parameter Syntax.

import parso

code = """def func[T](arg1: T, arg2: T) -> T:
    return arg1 + arg2"""

module = parso.parse(code, version='3.12')
expr = module.children[0]
print(expr) 
print(expr.get_code()) 

output

<PythonErrorNode: def func@1,0>
def func

This example is def, but classes may be similar.

It would be very helpful if you could support the new grammar.
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions