fix(11090): skip translate_dict_call when type alias dict call#11246
Closed
hi-ogawa wants to merge 1 commit intopython:masterfrom
Closed
fix(11090): skip translate_dict_call when type alias dict call#11246hi-ogawa wants to merge 1 commit intopython:masterfrom
hi-ogawa wants to merge 1 commit intopython:masterfrom
Conversation
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this pull request
Nov 3, 2025
Resolves a bad false negative and a false positive Previously, for `D = dict[str, str]` we would require a type annotation for `d = D()` and we would fail to error on `D(x=1)` Fixes python#11093, fixes python#11246
Member
|
This is superseded by #20170 |
wyattscarpenter
pushed a commit
to wyattscarpenter/mypy
that referenced
this pull request
Nov 3, 2025
Resolves a bad false negative and a false positive Previously, for `D = dict[str, str]` we would require a type annotation for `d = D()` and we would fail to error on `D(x=1)` Fixes python#11093, fixes python#11246, fixes python#13320, fixes python#16047
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.
Description
Fixes #11093
I explained what I analyzed about the issue in the comment #11093 (comment), so I would appreciate if someone could take a loot at it together with this PR.
Clearly, my fix is nothing but a workaround for the specific case in the issue, but surprisingly there is no regression in exisiting tests. So, I made this PR anyway as a starting point to ask some opinions about the issue itself. (Also, maybe CI will show me some regression).
It's highly likely that I'm missing some important use of
SemanticAnalyzer.translate_dict_call, but I couldn't figure it out by myself.Thanks a lot for the review!
Test Plan
I added new tests in
check-type-aliases.test:testTypeAliasDictNoVarAnnotatedError,testTypeAliasListNoVarAnnotatedError.I think the relevant existing tests are mostly in
check-typeddict.testand especially this test case:testCanCreateTypedDictInstanceWithDictCall.