Remove the Anys from mypy/config_parser.py#19637
Draft
wyattscarpenter wants to merge 17 commits intopython:masterfrom
Draft
Remove the Anys from mypy/config_parser.py#19637wyattscarpenter wants to merge 17 commits intopython:masterfrom
wyattscarpenter wants to merge 17 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Oh, that's funny. Now the only failing tests are the tests we put in to check the values the other way... Makes sense, I suppose. (Although... it only fails some of the time?! (oh, it's only with mypyc compiled... time to file an issue there. Cross-reference: mypyc/mypyc#1130)) |
wyattscarpenter
commented
Aug 14, 2025
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
this actually is starting to collide with the other places Any is used, which is getting annoying, but you have to commit incremental progress at some time...
for more information, see https://pre-commit.ci
also, trivial copyediting
this actually did not matter for the code, I guess. The only reason to change it was because mypy was complaining because mypy doesn't allow redefinition that way (at least with these settings). But instead of beating mypy into doing what I want, I just made the types follow the error message here.
for more information, see https://pre-commit.ci
This attempts to get at mypy/config_parser.py:620: error: Incompatible types in assignment (expression has type tuple[int, int], variable has type Optional[bool]) [assignment] however, I think this leaves v undefined in the else path, which is bad
for more information, see https://pre-commit.ci
502ec62 to
27b1880
Compare
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
This pull request removes the Anys (and the ignore) from mypy/config_parser.py, fixing #19566. This is a refactor, but it also ensures that the class of bugs (unfriendly error messages) triggered by runtime type errors do not occur here further. Sort of. Somewhat. Actually there are still a number of implicit Anys in the code that sneak in through the stubs from typeshed, sad to say.
Even adding this block at the top doesn't stop them:
#mypy: disallow-any-expr, disallow_any_unimported, disallow_any_decorated, disallow_any_explicit, disallow_any_generics, disallow_subclassing_anyBut, anyway, it prevents... some future bugs.