mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-53104 Support PEP 673 typing.Self type
GitOrigin-RevId: 8efc65725580510dc3e9a93e1242e1a69032c8f1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3056a721f1
commit
cad1138e59
@@ -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>
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user