Mypy config changes & enable a few more checks - #133
Open
CoolCat467 wants to merge 4 commits into
Open
Conversation
Also show tracebacks if mypy crashes as well as error codes and column numbers for reported errors.
CoolCat467
commented
Aug 4, 2026
CoolCat467
commented
Aug 4, 2026
| # Extract generic class from GenericAlias, e.g. list[str] --> list | ||
| if type(dstType) is GenericAlias: | ||
| dstType = typing.get_origin(dstType) | ||
| assert not isinstance(dstType, GenericAlias) |
Author
There was a problem hiding this comment.
I am slightly worried about this line at runtime, would like a double check that this is correct.
Owner
There was a problem hiding this comment.
Yes, this looks correct to me because:
- isinstance(list[str], GenericAlias) == True
- isinstance(get_origin(list[str]), GenericAlias) == False (it's just <class 'list'>)
This also works with nested containers, e.g. get_origin(list[list[str]]) == <class 'list'>.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In this pull request, we tell mypy which paths to check so you can simply do
mypyand check all relevant files instead of running into future cases where if things were to get more complicated, needing to change which files to check in multiple places.Turned on
warn_unreachableand dealt with new errors from this.Turned on
local_partial_typesto match the results of the mypy daemon (might not be necessary, I think they said they wanted to maketruethe default eventually in a blog post a while ago exactly because of this)We also show more diagnostic information for reported errors and show tracebacks in the event mypy crashes.
Also added a few missing annotations, mainly in
mainwindowWas trying out turning on
warn_unused_ignores, but ran into issues with the multiple UI backend shenanigans stuff and decided not to deal with that right now, but left it as commented out because it was useful to make sure my changes weren't adding anything new.