I have yet to read the whole PEP, and I haven't written any serious Python, either, but I find this to be very well written.<p>It uses a simple example of a "Circle" class, a subclass of "Shape":<p><pre><code> class Shape:
def set_scale(self, scale: float) -> Shape:
self.scale = scale
return self
Shape().set_scale(0.5) # => Shape
class Circle(Shape):
def set_radius(self, r: float) -> Circle:
self.radius = r
return self
Circle().set_scale(0.5) # *Shape*, not Circle
Circle().set_scale(0.5).set_radius(2.7)
# => Error: Shape has no attribute set_radius
</code></pre>
The error occurs because right now, Python cannot see that `self` is a `Circle`.<p>This PEP fixes that.
Python type hints are becoming easier to use every day. They started really terrible, but now with "|" and list/set/dict[] most common use cases are covered.<p>Now I would love to iter[] replace typing.Iterable[], callable[] replace typing.Callable[], and a shortcut for Annotated (maybe & ?).