Skip to content

Commit

Permalink
Merge pull request #4090 from pallets/stream-type
Browse files Browse the repository at this point in the history
improve typing for `stream_with_context`
  • Loading branch information
davidism committed May 21, 2021
2 parents 6b1c4e9 + 7ab934f commit 9f606a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Unreleased
same blueprint to be registered multiple times with unique names for
``url_for``. Registering the same blueprint with the same name
multiple times is deprecated. :issue:`1091`
- Improve typing for ``stream_with_context``. :issue:`4052`


Version 2.0.0
Expand Down
6 changes: 4 additions & 2 deletions src/flask/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def get_load_dotenv(default: bool = True) -> bool:


def stream_with_context(
generator_or_function: t.Union[t.Generator, t.Callable]
) -> t.Generator:
generator_or_function: t.Union[
t.Iterator[t.AnyStr], t.Callable[..., t.Iterator[t.AnyStr]]
]
) -> t.Iterator[t.AnyStr]:
"""Request contexts disappear when the response is started on the server.
This is done for efficiency reasons and to make it less likely to encounter
memory leaks with badly written WSGI middlewares. The downside is that if
Expand Down

0 comments on commit 9f606a8

Please sign in to comment.