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 Jan 5, 2022
Merged
Conversation
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`.
Closed
clokep
approved these changes
Jan 5, 2022
Member
clokep
left a comment
There was a problem hiding this comment.
Seems reasonable, needs to remove some unused imports though!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See commit messages.