PY-53104 Support PEP 673 typing.Self type

GitOrigin-RevId: 8efc65725580510dc3e9a93e1242e1a69032c8f1
This commit is contained in:
andrey.matveev
2022-10-19 09:45:15 +00:00
committed by intellij-monorepo-bot
parent 3056a721f1
commit cad1138e59
24 changed files with 904 additions and 74 deletions
+9
View File
@@ -0,0 +1,9 @@
from typing import Self
class A:
def foo(self) -> list[Self]:
...
class B(A)
def bar(self) -> Self:
...
B().foo()[0].<caret>
@@ -0,0 +1,10 @@
from typing import Self
class OuterClass:
class A:
def foo(self) -> list[Self]:
...
class B(A)
def bar(self) -> Self:
...
OuterClass.B().foo()[0].<caret>
+9
View File
@@ -0,0 +1,9 @@
from typing import Self
class A:
def foo(self) -> Self:
...
class B(A)
def bar(self) -> Self:
...
B().foo().<caret>
@@ -0,0 +1,8 @@
from typing import Self
class HasNestedFunction:
x: int = 42
def foo(self, inner_self: Self) -> None:
print(inner_self.<caret>)
@@ -0,0 +1,12 @@
from typing import Self
class HasNestedFunction:
x: int = 42
def foo(self) -> None:
def nested(z: int, inner_self: Self) -> Self:
print(inner_self.<caret>)
return inner_self
nested(42, self)