Skip to content

Support attrs alias and private attributes in st.builds#3807

Merged
Zac-HD merged 2 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:attrs-private-bug
Dec 8, 2023
Merged

Support attrs alias and private attributes in st.builds#3807
Zac-HD merged 2 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:attrs-private-bug

Conversation

@Liam-DeVoe
Copy link
Copy Markdown
Member

@Liam-DeVoe Liam-DeVoe commented Dec 7, 2023

Closes #3791.

More generally, adds support for attr's alias parameter. On master, the following errors, for instance:

@attr.s
class HasAliasedAttribute:
    x: int = attr.ib(alias="crazyname")

st.builds(HasAliasedAttribute)

Attrs also helpfully fills in alias with the correctly-stripped version of private attributes, which is why this fixes the linked issue.

attrs only added alias in 22.2.0. I probably could have thrown a if attrs.__version__ in here and made things backwards compatible, but it would have complicated things, so I've taken the easier option of bumping the dependency. There is precedence for this, but if this is a tough sell I can work on continuing to support previous versions.

P.S. I thought I would take a small break from IR pulls to do some good ol' bug fixing. I'm continuing to work on migrating the datatree to the IR, though! 🙂

Copy link
Copy Markdown
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Nice work!

extras_require=extras,
install_requires=[
"attrs>=19.2.0",
"attrs>=22.2.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was pretty nervous about this, but checking download stats it seems likely to be fine 🙂

@Zac-HD Zac-HD merged commit 650adc9 into HypothesisWorks:master Dec 8, 2023
@Liam-DeVoe Liam-DeVoe deleted the attrs-private-bug branch December 8, 2023 03:58
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.

builds fails when used with attrs classes containing private attributes

2 participants