Skip to content

Commit

Permalink
fix mypy findings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Aug 23, 2024
1 parent 2d31dce commit 176fdfa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/flask/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,21 @@ def get_load_dotenv(default: bool = True) -> bool:
return val.lower() in ("0", "false", "no")


@t.overload
def stream_with_context(
generator_or_function: t.Iterator[t.AnyStr],
) -> t.Iterator[t.AnyStr]: ...


@t.overload
def stream_with_context(
generator_or_function: t.Callable[..., t.Iterator[t.AnyStr]],
) -> t.Callable[[t.Iterator[t.AnyStr]], t.Iterator[t.AnyStr]]: ...


def stream_with_context(
generator_or_function: t.Iterator[t.AnyStr] | t.Callable[..., t.Iterator[t.AnyStr]],
) -> t.Iterator[t.AnyStr]:
) -> 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
2 changes: 1 addition & 1 deletion src/flask/json/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _default(o: t.Any) -> t.Any:
return str(o)

if dataclasses and dataclasses.is_dataclass(o):
return dataclasses.asdict(o)
return dataclasses.asdict(o) # type: ignore[call-overload]

if hasattr(o, "__html__"):
return str(o.__html__())
Expand Down

0 comments on commit 176fdfa

Please sign in to comment.