parso icon indicating copy to clipboard operation
parso copied to clipboard

parso can't parse PEP 695: Type Parameter Syntax

Open heavenshell opened this issue 2 years ago • 0 comments

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.

heavenshell avatar Dec 23 '23 15:12 heavenshell