attrs type annotation support in builds() or from_type() #4098
Labels
enhancement
it's not broken, but we want it to be better
interop
how to play nicely with other packages
Modern
attrs
supports annotations just like dataclasses, but hypothesis doesn't handle them as well. (This is a mix between a bug report and feature request 😄 )For example,
1) error from required attribute
results in an unexpected error — I expect it would handle it the same as dataclass.
2) and if I add a default to
age
:then this results in always using
age=0
although I expect that it would match the behavior of dataclass. (Shown using pytest's--hypothesis-verbosity=debug
)Workaround
version info
This is with hypothesis 6.108.2, attrs 23.1.0, and python3.11
Discussion
I see that https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.builds has a blurb about attrs
but these behaviors were still unexpected and the workaround wasn't clear.
The text was updated successfully, but these errors were encountered: