Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
14169b2a
Commit
14169b2a
authored
Feb 04, 2017
by
Berker Peksag
Browse files
Options
Browse Files
Download
Plain Diff
Issue #29198: Merge from 3.5
parents
3746619b
38962a6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
Doc/library/typing.rst
Doc/library/typing.rst
+33
-0
No files found.
Doc/library/typing.rst
View file @
14169b2a
...
@@ -689,6 +689,39 @@ The module defines the following classes, functions and decorators:
...
@@ -689,6 +689,39 @@ The module defines the following classes, functions and decorators:
yield start
yield start
start += 1
start += 1
.. class:: AsyncGenerator(AsyncIterator[T_co], Generic[T_co, T_contra])
An async generator can be annotated by the generic type
``AsyncGenerator[YieldType, SendType]``. For example::
async def echo_round() -> AsyncGenerator[int, float]:
sent = yield 0
while sent >= 0.0:
rounded = await round(sent)
sent = yield rounded
Unlike normal generators, async generators cannot return a value, so there
is no ``ReturnType`` type parameter. As with :class:`Generator`, the
``SendType`` behaves contravariantly.
If your generator will only yield values, set the ``SendType`` to
``None``::
async def infinite_stream(start: int) -> AsyncGenerator[int, None]:
while True:
yield start
start = await increment(start)
Alternatively, annotate your generator as having a return type of
either ``AsyncIterable[YieldType]`` or ``AsyncIterator[YieldType]``::
async def infinite_stream(start: int) -> AsyncIterator[int]:
while True:
yield start
start = await increment(start)
.. versionadded:: 3.5.4
.. class:: Text
.. class:: Text
``Text`` is an alias for ``str``. It is provided to supply a forward
``Text`` is an alias for ``str``. It is provided to supply a forward
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment