Allow attrs class object as input of attrs.fields #1400
Open
Description
Unless I am mistaken, one cannot use attrs.fields
on a attrs class object, unlike attrs.has
. The workaround is simple, either attrs.fields(type(obj))
or obj.__attrs_attrs__
. It would be nice to be able to use attrs.fields
directly.
@attrs.define
class Hello():
a = attrs.field()
b = attrs.field()
# This works
attrs.fields(Hello)
# But this doesn't (yet)
attrs.fields(Hello(1, 2))
# NB: this works though
attrs.has(Hello)
attrs.has(Hello(1, 2))
Thanks for the awesome library
Metadata
Assignees
Labels
No labels