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 @dataclass(frozen=True) fail on name shadowing #12088

Closed
wants to merge 2 commits into from
Closed

Fix @dataclass(frozen=True) fail on name shadowing #12088

wants to merge 2 commits into from

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 28, 2022

There are two things that I've done:

  1. Now we clear attributes from dataclass that are shadowed by methods. It is helpful, so __call__ won't be considered a dataclass attribute, the same as runtime does
  2. assert -> if change to be safe and not fail. Why I want to be extra safe? Because we can shadow attrs with class, import, import from, @property possibly something else. I don't want to dive deep into supporting everything here, just not crashing is good enough

Feedback is welcome!

Closes #12084

This pull request was closed.
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.

mypy crashes on callable frozen dataclass
1 participant