diff --git a/docs/guides/writing_stubs.rst b/docs/guides/writing_stubs.rst index c9c642aba..7964566c9 100644 --- a/docs/guides/writing_stubs.rst +++ b/docs/guides/writing_stubs.rst @@ -657,6 +657,12 @@ Yes:: @classmethod def create(cls) -> Self: ... + _T = TypeVar("_T") + + class Box(Generic[_T]): + # This method is only available on boxes containing strings. + def upper(self: Box[str]) -> str: ... + No:: class Foo: