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:
parent
7abeffc60d
commit
6a74c9ebaf
11
pep-0484.txt
11
pep-0484.txt
|
@ -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
|
||||||
=====================
|
=====================
|
||||||
|
|
Loading…
Reference in New Issue