[Python] Even a feature that you do not use can bite you

When annotation facilities were originally introduced (see PEP-3107), they weren't officially specifically for type checking - input to then-research-project third party static type checkers was certianly called out as one possible use case, but it was left entirely up to third-party tools what interpretation was put on the annotations.

Of course since PEP-3107 there's been PEP-483, PEP-484, PEP-526, PEP-563 steadily trending toward using the facility solely for type hints. Only in PEP-563 is non-type-hint use of the annotations really deprecated though:

With this in mind, uses for annotations incompatible with the aforementioned PEPs should be considered deprecated.

and the semantics will eventually change so that they're not evaluated expressions:

In Python 4.0, function and variable annotations will no longer be evaluated at definition time.

So, beware viewing them with hindsight assuming they were always "for" type declarations. They are now, but the history is more complex.

Aside: With regard to optional static type hints for python I much preferred that where: block [new keyword syntaxproposal mentioned in PEP-484 all along. But hey, I can make my own language with beer and hookers I guess if I don't like it...

/r/programming Thread Parent Link - blog.petrzemek.net