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

Update mypy and various typing improvements #3393

Merged
merged 5 commits into from
Jun 7, 2024

Conversation

bdarnell
Copy link
Member

@bdarnell bdarnell commented Jun 7, 2024

Picks up most of the open typing-related issues and PRs; see individual commits for details.

Fixes #3328
Fixes #3354
Fixes #3050
Fixes #3314

Adapt to newer upstream types for AbstractEventLoop
Revealed an issue in websocket.py in which bytes were used when it
should have been str. This avoided being a bug because something
down the line was converting it to str but it was still a logical
type error.

The change to httputil.py was taken from tornadoweb#3329 (thanks mslynch).

Closes tornadoweb#3329
Fixes tornadoweb#3328
Its default type is `Tuple[str, str, str, str, str, str, str]`, which
can only be overridden by a tuple of the exact same length.

This change originated in tornadoweb#3354 (thanks alexmv and andersk).

Closes tornadoweb#3354
In practice, UIModule.render often returns the
result of self.render_string, which returns bytes.
In fact, we have an example of that in this file
which had a type ignore comment. UIModule.render
may now return either str or bytes and downstream
code is responsible for handling this. (Note that
the new call to _unicode appears to be redundant
since the Template module's bytes return was
already working correctly, but this conversion is
necessary to satisfy the type checker.)

Fixes tornadoweb#3050
This method has always accepted both asyncio and concurrent futures,
but the type hint incorrectly indicated that it only accepted asyncio
futures.

Fixes tornadoweb#3314
@bdarnell bdarnell merged commit 74e7c98 into tornadoweb:master Jun 7, 2024
12 checks passed
@bdarnell bdarnell deleted the typing branch June 7, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant