Open
Description
I have been trying to use attr.make_class
to create a class based on type annotations. This is exemplified by the following code:
import attr
import inspect
class Test:
a: int
b: str
aTest = attr.frozen(Test)
sig = inspect.get_annotations(Test)
print(sig) # {"a": int, "b": str}
# fails with AttributeError: type object 'int' has no attribute 'type'
bTest = attr.make_class("Test", sig, frozen=True, on_setattr=True, auto_attribs=True)
The intent were for bTest
to be equivalent to aTest
, but generated programatically. However, that doesn't seem to work. What is the standard way to create an attr class programmatically from type annotations?