You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to use attr.make_class to create a class based on type annotations. This is exemplified by the following code:
importattrimportinspectclassTest:
a: intb: straTest=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?