Skip to content

Commit 7ab934f

Browse files
committed
improve typing for stream_with_context
1 parent 6b1c4e9 commit 7ab934f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Unreleased
3535
same blueprint to be registered multiple times with unique names for
3636
``url_for``. Registering the same blueprint with the same name
3737
multiple times is deprecated. :issue:`1091`
38+
- Improve typing for ``stream_with_context``. :issue:`4052`
3839

3940

4041
Version 2.0.0

src/flask/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def get_load_dotenv(default: bool = True) -> bool:
6464

6565

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

0 commit comments

Comments
 (0)