tornado
tornado copied to clipboard
Inaccurate typing on HTTPHeaders
HTTPHeaders.get should return str | None, but type checkers aren't able to infer that because it extends MutableMapping without type parameters:
from typing_extensions import reveal_type
from tornado.httputil import HTTPHeaders
h = HTTPHeaders()
reveal_type(h.get('a-header'))
yields Union[Any, None] on mypy and Unknown | None on Pyright.
Adding the type parameters [str, str] to the extended MutableMapping would correct the type to str | None.