Consider the following class:
@dataclass
class Point:
id: int
x: int
y: int
@property
def distance_from_zero(self): return (self.x**2 + self.y**2)**0.5
color: tuple #RGB or something...
I know that I can get the annotations from the __annotations__ variable, or the fields function from dataclasses.fields and in order.
I also know that the normal methods of any object can be read with dir or using the __dict__ method.
But what I'm after is something that can give me both in the right order, in the above case, it'll be something like:
>>>get_all_fields(Point)
['id', 'x', 'y', 'distance_from_zero', 'color']
The only thing i can think of is using something like the inspect module to read the actual code and somehow find the order. But that sounds really nasty.