3 ms·
> They're glorified comments This was always kinda false (type hints can be composed unlike eg docstring param @type). But with the introduction of dataclass,
by kortex 6y ago
> They're glorified comments
This was always kinda false (type hints can be composed unlike eg docstring param @type). But with the introduction of dataclass, this is empirically false. You can readily hook into the type hints, reflect on them, use it to marshal data, etc. Using __post_init__, you can leverage any kind of runtime checks you want to enforce invariants.
Also type hints greatly help transpilation.
You don't need 100% to reap the benefits. In fact I will annotate small bits of un-typed code and it makes it way easier to reason about.