[Python-ideas] Proposal: Use mypy syntax for function annotations

Steven D'Aprano steve at pearwood.info
Thu Aug 14 19:45:12 CEST 2014


On Wed, Aug 13, 2014 at 05:51:40PM -0430, Juancarlo Añez wrote:

> Function annotations are not available in Python 2.7, so promoting
> widespread use of annotations in 3.5 would be promoting code that is
> compatible only with 3.x, 

Yes. You say that as if it were a bad thing. It is not. Python 3 is 
here to stay and we should be promoting Python 3 only code. There is 
absolutely no need to apologise for that fact. If people are happy with 
Python the way it is in 2.7, or 1.5 for that matter, that's great, they 
can stay on it for ever, but all new features are aimed at 3.x and not 
2.x or 1.x.


> when the current situation is that much effort is
> being spent on writing code that works on both 2.7 and 3.4 (most
> libraries?).

There's no reason why all new code should be aimed at 2.x and 3.x. But 
even for code which is, the nice thing about this proposal is that it's 
optional, so you can run your type-check using mypy under Python 3.x and 
still get the benefit of it when running under 2.x.


> Independently of its core merits, this proposal should fail unless
> annotations are added to Python 2.8.

There will be no Python 2.8, and no Python 2.9 either. New features go 
into 3.x.



-- 
Steven


More information about the Python-ideas mailing list