KEMBAR78
gh-124176: Add special support for dataclasses to `create_autospec` by sobolevn · Pull Request #124429 · python/cpython · GitHub
Skip to content

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