<div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">Well, I fact, I was playing with metaclasses and descriptors, and I was thinking about a way to use the famous variable annotation to instatiate decrptors like this:</span><br></div><div><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">class Point(metaclass=MyMeta):</span><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">    x: int</span><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">    y: int</span><br></div><div><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">class Circle(metaclass=MyMeta):</span><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">    center: Point</span><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">    radius: PositiveInteger</span><br></div><div><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">Here the radius must be [strictly] positive, but since I'm using the annotations to get the type to test in the __set__ method of the descriptor, I didn't found a more elegant way than that...</span><br></div><div><br></div><div><span class="font" style="font-family:menlo, consolas, courier new, monospace, sans-serif">And it was before I knew the existance of dataclasses!!! I was pretty shocked by the way. Maybe I can make this compatible with it anyway.</span><br></div>