Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Typing updates for recent mypy versions#481

Merged
DMRobertson merged 4 commits intomainfrom
dmr/mypy-updates
Jan 5, 2022
Merged

Typing updates for recent mypy versions#481
DMRobertson merged 4 commits intomainfrom
dmr/mypy-updates

Conversation

@DMRobertson
Copy link
Copy Markdown
Contributor

See commit messages.

David Robertson added 2 commits January 5, 2022 17:53
A version of mypy has been released which includes
python/typeshed#6150. (Typeshed is vendored with mypy these days.) We
can now remove the redundant cast.
Since python/typeshed#5681 (vendored in recent mypy releases),
StreamHandler is now generic over its stream. This causes us pain:

> Missing type parameters for generic type "StreamHandler"

And I couldn't find a satisfactory type parameter that worked here.

- a `TimedRotatingFileHandler` instance is a `FileHandler` which is a
`StreamHandler[TextIOWrapper]`. - the instance `StreamHandler()` (which
writes to stdout) is overloaded to be a `StreamHandler[TextIO]`

`handler: StreamHandler[TextIO]` didn't work. I don't fully understand
the difference between the concrete TextIOWrapper and the abstract
TextIO (the former looks to be compatible with the latter?). I think the
StreamHandler type parameter would need to be covariant for this to
work.

In any case, we're not making use of any of the stream or file specific
attributes here. So let's just mark it as a general `Handler`.
@DMRobertson DMRobertson requested a review from a team as a code owner January 5, 2022 18:12
@DMRobertson DMRobertson linked an issue Jan 5, 2022 that may be closed by this pull request
Copy link
Copy Markdown
Member

@clokep clokep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, needs to remove some unused imports though!

@DMRobertson DMRobertson merged commit abc63a7 into main Jan 5, 2022
@DMRobertson DMRobertson deleted the dmr/mypy-updates branch January 5, 2022 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mypy CI is failing

2 participants