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

Wes Turner wes.turner at gmail.com
Sat Aug 16 05:16:30 CEST 2014


> Couldn't you do that today in Python with a suitably sophisticated
> function decorator? The range/type checking would happen before the
> user's actual function is called.

PyContracts does this; with (1) an @contract decorator,
(2) Python 3 annotations,
(3) with :type: and :rtype: docstrings

... http://www.reddit.com/r/Python/comments/2dh036/pythonideas_proposal_use_mypy_syntax_for_function/#cjq09bu
:

> +1 for static typing for certain problems.
> [...]
> Static type checking at compile time (linting) looks really neat.
> [...]
> Do we need a separate approach for actual type assertions
> at runtime? Will that ever be in scope for mypy?


More information about the Python-ideas mailing list