*Memo:
- mypy test.py
- mypy 1.18.2
- Python 3.14.0
- Windows 11
The function which only returns None gets the error if defining and calling the function, and printing the return value as shown below:
def func() -> None:
return None
print(func())
# Error
error: "func" does not return a value (it only ever returns None)
But, only defining and calling the function doesn't get the error as shown below:
def func() -> None:
return None
func()
# No error
And, only defining the function doesn't get the error as shown below:
def func() -> None:
return None
# No error
So, the error should occur at the timing when only defining the function as shown below:
def func() -> None:
return None
# Error
error: "func" does not return a value (it only ever returns None)