I have a dataclass with typed attributes, using types I defined as seen below:
from dataclasses import dataclass
PositiveFloatType = NewType("PositiveFloat", float)
@dataclass(init=False, frozen=True)
class Foo:
bar: PositiveFloatType = 1
On runtime, I'd like to get to the type of Foo.bar. I.e., I'd like to find all attributes of class Foo, and know their type names, in case of Foo.bar - get "PositiveFloatType".
I tried using inspect to no avail. Is there any way to do this?