Skip to content

Replace typing_extensions -> typing in examples #1987

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion docs/guides/unreachable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ As an example, consider this simple calculator:
.. code:: python

import enum
from typing_extensions import Never
from typing import Never
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss on the issue for now


def assert_never(arg: Never) -> Never:
raise AssertionError("Expected code to be unreachable")
Expand Down
12 changes: 4 additions & 8 deletions docs/reference/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ for a more faithful type annotation:

.. code-block:: python

from typing import Callable, TypeVar
from typing_extensions import ParamSpec
from typing import Callable, ParamSpec, TypeVar

P = ParamSpec('P')
T = TypeVar('T')
Expand All @@ -668,8 +667,7 @@ alter the signature of the input function:

.. code-block:: python

from typing import Callable, TypeVar
from typing_extensions import ParamSpec
from typing import Callable, ParamSpec, TypeVar

P = ParamSpec('P')
T = TypeVar('T')
Expand All @@ -692,8 +690,7 @@ Or insert an argument:

.. code-block:: python

from typing import Callable, TypeVar
from typing_extensions import Concatenate, ParamSpec
from typing import Callable, Concatenate, ParamSpec, TypeVar

P = ParamSpec('P')
T = TypeVar('T')
Expand Down Expand Up @@ -774,8 +771,7 @@ 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/reference/protocols.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ You can define your own protocol class by inheriting from the special

.. 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 @@ -231,8 +230,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 @@ -260,7 +258,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 @@ -303,8 +301,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 @@ -328,8 +325,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, TypeVar, Protocol

T = TypeVar('T')

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/quality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ then the following file tests ``foo.py``:

.. code-block:: python

from typing_extensions import assert_type
from typing import assert_type

assert_type(bar(42), str)

Expand Down