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

Typing updates for recent mypy versions #481

Merged
merged 4 commits into from Jan 5, 2022
Merged

Conversation

DMRobertson
Copy link
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
Contributor

@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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mypy CI is failing
2 participants