Skip to content
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

Fix inference for attrs.fields #15688

Merged
merged 3 commits into from
Jul 29, 2023
Merged

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #15393. A little hacky, but not an unreasonable way of providing type context.

@github-actions

This comment has been minimized.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I don't think this is a hack. This is more consistent with e.g. tuple_fallback() than the current behavior: tuple_fallback() just returns the fallback if it is non-trivial, so here too, we should just copy the logic for instances, if the fallback is non-trivial.

mypy/checker.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit 002502a into python:master Jul 29, 2023
17 checks passed
@hauntsaninja hauntsaninja deleted the attrs-fix branch July 29, 2023 22:13
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull request Aug 31, 2023
This e.g. makes sure both code paths receive my fix in python#15688
JukkaL pushed a commit that referenced this pull request Sep 1, 2023
This e.g. makes sure both code paths receive my fix in #15688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants