-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Using field transformer breaks integration with hypothesis #821
Comments
@sscherfke? 😇 |
I will take a look, but I can’t tell when. I’m currently quite busy with work. :) |
sscherfke
added a commit
that referenced
this issue
Jun 13, 2021
10 tasks
hynek
added a commit
that referenced
this issue
Sep 22, 2021
* Convert transformed attrs to AttrsClass Fixes: #821 * Add cangelog entry * Only call AttrsClass once * Calm mypy by inline the AttrsClass call * Defer AttrsClass creation as long as possible Co-authored-by: Hynek Schlawack <[email protected]>
swhmirror
pushed a commit
to SoftwareHeritage/swh-model
that referenced
this issue
Oct 17, 2022
When using attr < 21.3.0, adding field transformer breaks attrs integration with hypothesis, because attributes transformed with such function are not casted to generated AttrsClass, but remains just an list of attributes. This causes error in hypothesis by raising an AttributeError. As we use attr 21.2.0 in production and when building debian buster package, add a workaround for that issue as explained here: python-attrs/attrs#821.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding field transformer according to documentation (i.e. as a function of type
Callable[[type, list[attr.Attribute[Any]]], list[attr.Attribute[Any]]]
)breaks
attrs
integration with hypothesis, because attributes transformed with such function are not casted to generatedAttrsClass
, but remains just an list of attributes (here)This causes error in hypothesis here, because
fields
is an list, not anAttrsClass
instance, and thereforegetattr(fields, name)
raises anAttributeError
.Easy workaround for that is just to create an
AttrsClass
again inside field transformer, like so:...but it's not very handy nor pretty, and messes with typing. So, I would very thankful if it could be resolved within
attrs
(it would be quite easy, I guess).BTW. I love your package, awesome job! Cheers!
The text was updated successfully, but these errors were encountered: