Hackbraten 23 hours ago

> yet another Python thing I'd have to try to keep in my mind despite it being months since I used them last.

Typing hints are also a moving target: they have changed, sometimes significantly, on every minor Python release since they came to be.

The `Optional` type came and went (being replaced by the new Union syntax.) Type classes are usually born in the `typing` module, then some of them get moved to `collections`, `abc`, or `collections.abc`. Some types have even been moved several times. `TypeAlias` came and went (replaced by `type`). `List` became `list`. `Tuple` became `tuple`. Forward declarations require a workaround by using string literals. But in Python 3.14, they no longer do, and the workaround will become deprecated.

I'm an evangelist for static type checking, and I never write a Python function signature without complete typing annotations. I also think that typing annotations in Python are evolving in a good way. However, for long-lived Python scripts, I highly recommend that developers are aware of, and factor in, the effort necessary to keep up with the evolution of static typing across Python versions. That effort spent on migrating is going to come on top of the mental load that typing hints already add to your plate.

3
maleldil 8 hours ago

The old stuff never stopped working, though. You can still use Optional, Union, TypeAlias, and import collection protocols from typing. You don't have to migrate if you don't want to. They're not even deprecated.

aragilar 40 minutes ago

I've seen multiple major projects (such a sphinx) break on newer versions of Python due to changes in typing. Typing should make the code more robust, not less.

Hackbraten 1 hour ago

I encourage you to open the `typing` documentation [0] and search for the word `deprecated`.

Spoiler alert: the search result will be three-figure.

Some of the results are already scheduled for removal.

[0]: https://docs.python.org/3/library/typing.html

hopfenspergerj 6 hours ago

Ruff can automatically upgrade all of the issues you mentioned to match your target minimum python version.

Hackbraten 1 hour ago

Good to know, thanks!

adammarples 8 hours ago

None of those things came and went, they came but did not go. They're all still here, even in the 3.14 beta.