fix mypy findings

This commit is contained in:
David Lord 2024-08-23 16:33:52 -07:00
parent 2d31dce826
commit 176fdfa000
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
2 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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__())