Skip to content

gh-124176: Add special support for dataclasses to create_autospec #124429

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

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Sep 24, 2024

Now creating autospecs from dataclass types is easier. We inspect all fields and add them to __dir__, so mock's spec will know about future dataclass instance fields.

Copy link
Member

@ericvsmith ericvsmith left a comment

Choose a reason for hiding this comment

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

I'm not a user of unittest.mock, but these changes look reasonable to me.

Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me as well.

Copy link
Contributor

@cjw296 cjw296 left a comment

Choose a reason for hiding this comment

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

Supportive of the change, just the code hygiene changes to make.

@bedevere-app
Copy link

bedevere-app bot commented Sep 26, 2024

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@sobolevn
Copy link
Member Author

@cjw296 done! 👍

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

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

LGTM! I especially like the test coverage.

Copy link
Contributor

@cjw296 cjw296 left a comment

Choose a reason for hiding this comment

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

Nice!

@sobolevn sobolevn merged commit 3a0e7f5 into python:main Sep 27, 2024
35 of 36 checks passed
@sobolevn
Copy link
Member Author

Thanks everyone! 🎉

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.

5 participants