Though I spend most my time writing Swift code, which definitely influences my preference.
Would you say this is "less readable substantially" than your example?
def max_width_of_vertical_area(points):
# type points: List of List of int
xs = sorted(x for x, _ in points)
return max(x2-x1 for x1, x2 in zip(xs, xs[1:]))Are Python type hints able to specify types like that?
My experience even before that was mostly with PyDev in eclipse. The trick back then was identifying good spots to add type-hints, afterwhich the "IDE" would take over and propagate them through the different variables and calls using static code analysis. It was surprisingly good and helped immensely with very few actual instances of types being hinted. Another one was PyCharm that would "save" or "cache" the types during debug/test runs and use them as type-hints without you explicitly having to define them.
Fancy example:
List[Dict[str, MyCustomTypeGeneric[str]]]
Which gives you a list of dictionaries with keys of type string, holding values MyCustomTypeGeneric with generic type str.
Yes, Iterable[Tuple[Number, Number]] is a valid type, though 2D points are probably Tuple[Real, Real] or just Complex, not Tuple[Number, Number].