PY-61877, PY-61878 PEP 695 Type Parameter Syntax: Control flow for type parameters and type aliases

GitOrigin-RevId: 2db381cbb97891296bae09e48c17b46eefa57a04
This commit is contained in:
Daniil Kalinin
2023-08-31 16:37:54 +02:00
committed by intellij-monorepo-bot
parent 1c5b0c5ac3
commit 65cc3ddfd0
10 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1 @@
type myType = str

View File

@@ -0,0 +1,5 @@
0(1) element: null
1(2) element: PyTypeAliasStatement
2(3) READ ACCESS: str
3(4) WRITE ACCESS: myType
4() element: null

View File

@@ -0,0 +1 @@
type myType[T: str, U: int] = Union[T, U]

View File

@@ -0,0 +1,12 @@
0(1) element: null
1(2) element: PyTypeParameter
2(3) WRITE ACCESS: T
3(4) READ ACCESS: str
4(5) element: PyTypeParameter
5(6) WRITE ACCESS: U
6(7) READ ACCESS: int
7(8) element: PySubscriptionExpression
8(9) READ ACCESS: Union
9(10) READ ACCESS: T
10(11) READ ACCESS: U
11() element: null

View File

@@ -0,0 +1,2 @@
class Clazz[T, U](BaseClass[T]):
pass

View File

@@ -0,0 +1,9 @@
0(1) element: null
1(2) element: PyTypeParameter
2(3) WRITE ACCESS: T
3(4) element: PyTypeParameter
4(5) WRITE ACCESS: U
5(6) element: PySubscriptionExpression
6(7) READ ACCESS: BaseClass
7(8) READ ACCESS: T
8() element: null

View File

@@ -0,0 +1,2 @@
def foo[T, U](a: T, b: U):
pass

View File

@@ -0,0 +1,8 @@
0(1) element: null
1(2) element: PyTypeParameter
2(3) WRITE ACCESS: T
3(4) element: PyTypeParameter
4(5) WRITE ACCESS: U
5(6) WRITE ACCESS: a
6(7) WRITE ACCESS: b
7() element: null