Skip to content

Commit dc0a8a9

Browse files
authored
Add a useful explicit receiver annotation example (#2364)
1 parent d44387d commit dc0a8a9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎docs/guides/writing_stubs.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,12 @@ Yes::
657657
@classmethod
658658
def create(cls) -> Self: ...
659659

660+
_T = TypeVar("_T")
661+
662+
class Box(Generic[_T]):
663+
# This method is only available on boxes containing strings.
664+
def upper(self: Box[str]) -> str: ...
665+
660666
No::
661667

662668
class Foo:

0 commit comments

Comments
 (0)