Skip to content

Commit fe4c850

Browse files
committed
Revert changes to wrting_stubs that should be made separately.
1 parent 61dafc4 commit fe4c850

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

docs/guides/writing_stubs.rst

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -337,46 +337,6 @@ No::
337337
DAY_FLAG: int
338338
NIGHT_FLAG: int
339339

340-
Overloads
341-
---------
342-
343-
All variants of overloaded functions and methods must have an ``@overload``
344-
decorator. Do not include the implementation's final non-`@overload`-decorated
345-
definition.
346-
347-
Yes::
348-
349-
@overload
350-
def foo(x: str) -> str: ...
351-
@overload
352-
def foo(x: float) -> int: ...
353-
354-
No::
355-
356-
@overload
357-
def foo(x: str) -> str: ...
358-
@overload
359-
def foo(x: float) -> int: ...
360-
def foo(x: str | float) -> Any: ...
361-
362-
Decorators
363-
----------
364-
365-
Include only the decorators listed :ref:`here <stub-decorators>`, whose effects
366-
are understood by all of the major type checkers. The behavior of other
367-
decorators should instead be incorporated into the types. For example, for the
368-
following function::
369-
370-
import contextlib
371-
@contextlib.contextmanager
372-
def f():
373-
yield 42
374-
375-
the stub definition should be::
376-
377-
from contextlib import AbstractContextManager
378-
def f() -> AbstractContextManager[int]: ...
379-
380340
Documentation or Implementation
381341
-------------------------------
382342

@@ -621,30 +581,3 @@ No::
621581
from typing import NamedTuple, TypedDict
622582
Point = NamedTuple("Point", [('x', float), ('y', float)])
623583
Thing = TypedDict("Thing", {'stuff': str, 'index': int})
624-
625-
Built-in Generics
626-
-----------------
627-
628-
:pep:`585` built-in generics are supported and should be used instead
629-
of the corresponding types from ``typing``::
630-
631-
from collections import defaultdict
632-
633-
def foo(t: type[MyClass]) -> list[int]: ...
634-
x: defaultdict[int]
635-
636-
Using imports from ``collections.abc`` instead of ``typing`` is
637-
generally possible and recommended::
638-
639-
from collections.abc import Iterable
640-
641-
def foo(iter: Iterable[int]) -> None: ...
642-
643-
Unions
644-
------
645-
646-
Declaring unions with the shorthand `|` syntax is recommended and supported by
647-
all type checkers::
648-
649-
def foo(x: int | str) -> int | None: ... # recommended
650-
def foo(x: Union[int, str]) -> Optional[int]: ... # ok

0 commit comments

Comments
 (0)