PEP 484: Add a note that misplaced type comments are errors for typecheckers (#133)

Fixes python/typing#210.

This behaviour with --fast-parser is in mypy since mid-May. It looks like nobody is complaining.
This commit is contained in:
Ivan Levkivskyi 2016-11-06 19:54:51 +01:00 committed by Guido van Rossum
parent 7abeffc60d
commit 6a74c9ebaf
1 changed files with 11 additions and 0 deletions

View File

@ -2027,6 +2027,17 @@ Notes:
def add(a, b): # type: (int, int) -> int def add(a, b): # type: (int, int) -> int
return a + b return a + b
- Misplaced type comments will be flagged as errors by a type checker.
If necessary, such comments could be commented twice. For example::
def f():
'''Docstring'''
# type: () -> None # Error!
def g():
'''Docstring'''
# # type: () -> None # This is OK
Rejected Alternatives Rejected Alternatives
===================== =====================