-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
gh-124176: create_autospec
must not change how dataclass defaults are mocked
#124724
base: main
Are you sure you want to change the base?
Conversation
…ults are mocked
I agree with the backport labels, since we want to backport the test case, even if the functional change doesn't apply cleanly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I've suggested some naming clarifications for the new test cases.
Co-authored-by: Alyssa Coghlan <[email protected]>
@ncoghlan thanks a lot for the helpful suggestions! I applied all of them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ready to me!
See #124176 (comment)
@ncoghlan found that my change introduced a behavior change (or even a regression) to dataclasses with defaults.
Before my change
create_autospec
would use the default's type for_spec_class
.After my change it would use the annotation's type.
Which is not always correct. For example,
int | str
would produce a__class__
oftypes.UnionType
People might rely on that, so no need to break this.