logoalt Hacker News

toxiktoday at 4:15 PM2 repliesview on HN

So the future behavior is deprecated before it ever became the default?


Replies

nyrikkitoday at 4:44 PM

It was an abandoned path even before 3.10, it just took longer to implement 649 and 749 than they expected.

But this is a "...will continue to exist with its current behavior at least..." is an important bit there.

From pep-0749:

     Sometime after the last release that did not support PEP 649 semantics (expected to be 3.13) reaches its end-of-life, from __future__ import annotations is deprecated. Compiling any code that uses the future import will emit a DeprecationWarning. This will happen no sooner than the first release after Python 3.13 reaches its end-of-life, but the community may decide to wait longer.
It has a good overview of the history.

https://peps.python.org/pep-0749/

js2today at 4:42 PM

Correct. Before the "from __future__ import annotations" behavior that converts annotations to strings became the default, they figured out a better mechanism for circular type annotations (making them lazy) that is implicitly backwards compatible and that didn't need to be guarded behind a future statement.

Ironically, the new default behavior (making type annotation evaluation lazy) is not backwards compatible with the "from __future__ import annotations" behavior of converting annotations to strings, so they can't just rip out "from __future__ import annotations" and instead it needs to be deprecated and removed over multiple releases.

Oh, what tangled webs we weave! :-)