Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update TypedDict import statements #16958

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/common_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Consider this example:

.. code-block:: python

from typing_extensions import Protocol
from typing import Protocol

class P(Protocol):
x: float
Expand All @@ -561,7 +561,7 @@ the protocol definition:

.. code-block:: python

from typing_extensions import Protocol
from typing import Protocol

class P(Protocol):
@property
Expand Down
8 changes: 4 additions & 4 deletions docs/source/error_code_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Example:

.. code-block:: python

from typing_extensions import TypedDict
from typing import TypedDict

class Point(TypedDict):
x: int
Expand All @@ -562,7 +562,7 @@ to have been validated at the point of construction. Example:

.. code-block:: python

from typing_extensions import TypedDict
from typing import TypedDict

class Point(TypedDict):
x: int
Expand Down Expand Up @@ -868,7 +868,7 @@ the return type affects which lines mypy thinks are reachable after a
``True`` may swallow exceptions. An imprecise return type can result
in mysterious errors reported near ``with`` statements.

To fix this, use either ``typing_extensions.Literal[False]`` or
To fix this, use either ``typing.Literal[False]`` or
``None`` as the return type. Returning ``None`` is equivalent to
returning ``False`` in this context, since both are treated as false
values.
Expand Down Expand Up @@ -897,7 +897,7 @@ You can use ``Literal[False]`` to fix the error:

.. code-block:: python

from typing_extensions import Literal
from typing import Literal

class MyContext:
...
Expand Down
3 changes: 1 addition & 2 deletions docs/source/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,7 @@ protocols mostly follow the normal rules for generic classes. Example:

.. code-block:: python

from typing import TypeVar
from typing_extensions import Protocol
from typing import Protocol, TypeVar

T = TypeVar('T')

Expand Down
14 changes: 5 additions & 9 deletions docs/source/protocols.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class:

.. code-block:: python

from typing import Iterable
from typing_extensions import Protocol
from typing import Iterable, Protocol

class SupportsClose(Protocol):
# Empty method body (explicit '...')
Expand Down Expand Up @@ -226,8 +225,7 @@ such as trees and linked lists:

.. code-block:: python

from typing import TypeVar, Optional
from typing_extensions import Protocol
from typing import TypeVar, Optional, Protocol

class TreeLike(Protocol):
value: int
Expand Down Expand Up @@ -255,7 +253,7 @@ rudimentary support for runtime structural checks:

.. code-block:: python

from typing_extensions import Protocol, runtime_checkable
from typing import Protocol, runtime_checkable

@runtime_checkable
class Portable(Protocol):
Expand Down Expand Up @@ -298,8 +296,7 @@ member:

.. code-block:: python

from typing import Optional, Iterable
from typing_extensions import Protocol
from typing import Optional, Iterable, Protocol

class Combiner(Protocol):
def __call__(self, *vals: bytes, maxlen: Optional[int] = None) -> list[bytes]: ...
Expand All @@ -323,8 +320,7 @@ a double underscore prefix is used. For example:

.. code-block:: python

from typing import Callable, TypeVar
from typing_extensions import Protocol
from typing import Callable, Protocol, TypeVar

T = TypeVar('T')

Expand Down
2 changes: 1 addition & 1 deletion docs/source/stubs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ For example:

.. code-block:: python

from typing_extensions import Protocol
from typing import Protocol

class Resource(Protocol):
def ok_1(self, foo: list[str] = ...) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions docs/source/typed_dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dictionary value depends on the key:

.. code-block:: python

from typing_extensions import TypedDict
from typing import TypedDict

Movie = TypedDict('Movie', {'name': str, 'year': int})

Expand Down Expand Up @@ -189,7 +189,7 @@ in Python 3.6 and later:

.. code-block:: python

from typing_extensions import TypedDict
from typing import TypedDict # "from typing_extensions" in Python 3.7 and earlier

class Movie(TypedDict):
name: str
Expand Down