Just refer to the spec in PEP 484 for straddling annotations instead of repeating the info in PEP 8.

This commit is contained in:
Guido van Rossum 2016-03-21 13:30:24 -07:00
parent d486abefaf
commit e1d8f55b86
1 changed files with 4 additions and 18 deletions

View File

@ -1289,21 +1289,8 @@ annotations are changing.
the library author's permission) through the typeshed repo [4]_. the library author's permission) through the typeshed repo [4]_.
- For code that needs to be backwards compatible, function annotations - For code that needs to be backwards compatible, function annotations
can be added in the form of comments. Basically, this Python 3 annotation:: can be added in the form of comments. See the relevant section of
PEP 484 [5]_.
def embezzle(self, account: str, funds: int = 1000000, **fake_receipts: str) -> None:
"""Embezzle funds from account using fake receipts."""
<code goes here>
is equivalent to the following::
def embezzle(self, account, funds=1000000, **fake_receipts):
# type: (str, int, **str) -> None
"""Embezzle funds from account using fake receipts."""
<code goes here>
The mypy type checker [5]_ currently supports this syntax, and other
type checkers are encouraged to adopt it.
.. rubric:: Footnotes .. rubric:: Footnotes
@ -1329,9 +1316,8 @@ References
.. [4] Typeshed repo .. [4] Typeshed repo
https://github.com/python/typeshed https://github.com/python/typeshed
.. [5] mypy type checker .. [5] Suggested syntax for Python 2.7 and straddling code
http://mypy-lang.org https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code
https://github.com/JukkaL/mypy