-
-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Labels
Description
I'm using attrs.make_class() to dynamically construct a class based on other attrs classes, and it would be nice to be able to specify the type of the fields on the generated class using attrs.field() instead of attr.ib(). In other words, this works:
fields = {
field.name: attr.ib(type=field.type)
for field in itertools.chain.from_iterable(
attrs.fields(t) for t in SOME_ATTRS_CLASSES
)
if not field.name.startswith("_")
}
MyClass = attrs.make_class("MyClass", fields)but this does not:
fields = {
field.name: attrs.field(type=field.type)
for field in itertools.chain.from_iterable(
attrs.fields(t) for t in SOME_ATTRS_CLASSES
)
if not field.name.startswith("_")
}
MyClass = attrs.make_class("MyClass", fields)