[Python-ideas] Proposal: Use mypy syntax for function annotations
Steven D'Aprano
steve at pearwood.info
Wed Aug 20 16:47:34 CEST 2014
On Wed, Aug 20, 2014 at 03:06:09PM +0100, Paul Moore wrote:
> On 14 August 2014 18:31, Steven D'Aprano <steve at pearwood.info> wrote:
> > opt-out and use something else:
> >
> > @use_spam_annotations
> > def frobnicate(x: spam, y: eggs)->breakfast:
> ...
> Which reminds me. Why is mypy exempt from the general recommendation
> to only use annotations on functions that are tagged with a decorator?
That's the whole point of Guido's proposal: he wants to bless, not mypy
precisely since that's an alternative implementation of Python, but
mypy's syntax as the standard use of annotations. Since it will be the
official standard, there's no need to flag it with a decorator, even if
CPython will not itself do anything with those annotations.
If Guido's suggestion is accepted, any linter, editor, IDE, Python
compiler, or other static tool will be entitled to assume that
annotations are type hints, using the mypy-derived syntax, at
least unless explicitly told not to.
--
Steven
More information about the Python-ideas
mailing list