Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate typing on HTTPHeaders #3328

Open
mslynch opened this issue Sep 28, 2023 · 0 comments · May be fixed by #3329
Open

Inaccurate typing on HTTPHeaders #3328

mslynch opened this issue Sep 28, 2023 · 0 comments · May be fixed by #3329

Comments

@mslynch
Copy link

mslynch commented Sep 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant