I am trying to write a type hint explicitly in a function definition
def annotated(x: int, y: str) -> bool:
return x < y
ran python3.5 -m mypy test.pyand received the following message
test.py:2: error: Unsupported operand types for > ("str" and "int")
It is right. But when I try to use a stub file
def annotated(x, y):
return x < y
def annotated(x: int, y: str) -> bool: ...
I have nothing. I saw this answer Using Mypy Local Stubs . So I try import.
from test import annotated
annotated(2, 3)
This is normal. I got
error: Argument 2 to "annotated" has incompatible type "int"; expected "str"
But the call annotated(2, 's')still got nothing.
So what should I do to check for illegal stub operation? Thanks
source
share