-
-
Notifications
You must be signed in to change notification settings - Fork 3k
TypedDict as default_factory in dataclasses is not inferred correctly #5723
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
Labels
Comments
This is actually not specific to dataclasses. It looks like typed dict class objects are never analyzed properly. There is a hack in |
23 tasks
In mypy 1.6.1, the output is
workaround:
|
pull bot
pushed a commit
to Dareh123/mypy
that referenced
this issue
Jun 9, 2025
Fixes python#3832 Fixes python#5723 Fixes python#17174 Improves python#7217 This is a sixth "major" PR toward python#7724. Previously access to "static" attributes (like type aliases, class objects) was duplicated in four places: * In `analyze_ref_expr()` * In `determine_type_of_member()` (for modules as subtypes of protocols) * In instance attribute access logic * In class attribute logic Most of these were somewhat incomplete and/or inconsistent, this PR unifies all four (there is still tiny duplication because I decided to limit the number of deferrals, i.e. preserve the existing logic in this respect). Some notable things that are not pure refactoring: * Previously we disabled access to type variables as class attributes. This was inconsistent with plain references and instance attributes that just return `Instance("typing.TypeVar")`. * Instance access plugins were only applied on `TypeInfo`s and `TypeAlias`es, now they are applied always. * Previously arguments kinds were sometimes not correct for TypedDict class objects with non-required keys. * I tweaked `TypeOfAny` in couple places to be more logical.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
Do you see the same issue after installing mypy from Git master? yes
The text was updated successfully, but these errors were encountered: