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]_.
- For code that needs to be backwards compatible, function annotations
can be added in the form of comments. Basically, this Python 3 annotation::
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.
can be added in the form of comments. See the relevant section of
PEP 484 [5]_.
.. rubric:: Footnotes
@ -1329,9 +1316,8 @@ References
.. [4] Typeshed repo
https://github.com/python/typeshed
.. [5] mypy type checker
http://mypy-lang.org
https://github.com/JukkaL/mypy
.. [5] Suggested syntax for Python 2.7 and straddling code
https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code