Skip to content

[3.10] bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148) #30179

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

Merged
merged 1 commit into from
Dec 18, 2021
Merged
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
17 changes: 8 additions & 9 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,12 @@ value of type :data:`Any` and assign it to any variable::

from typing import Any

a = None # type: Any
a = [] # OK
a = 2 # OK
a: Any = None
a = [] # OK
a = 2 # OK

s = '' # type: str
s = a # OK
s = '' # Inferred type of 's' is str
Copy link
Member

Choose a reason for hiding this comment

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

Why not ‘s: str = “”’? That’s what the original meant and some checkers allow overriding inferred types.

Copy link
Member

Choose a reason for hiding this comment

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

That's what I originally had, but @sobolevn convinced me to change it (and after he pointed it out, I decided I agreed with him 🙂) #30148 (comment)

s = a # OK

def foo(item: Any) -> int:
# Typechecks; 'item' could be any type,
Expand Down Expand Up @@ -1779,11 +1779,10 @@ Asynchronous programming
correspond to those of :class:`Generator`, for example::

from collections.abc import Coroutine
c = None # type: Coroutine[list[str], str, int]
...
x = c.send('hi') # type: list[str]
c: Coroutine[list[str], str, int] # Some coroutine defined elsewhere
x = c.send('hi') # Inferred type of 'x' is list[str]
async def bar() -> None:
x = await c # type: int
y = await c # Inferred type of 'y' is int

.. versionadded:: 3.5.3

Expand Down