You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Python file test.py with the content above.
Run mypy test.py
Expected Behavior
in both cases errors can be eliminated by adding just a return or return None at the end of both functions, but it is not really needed (does not change program behavior), because by default function without return statement at its end returns None which is a valid return value for Optional[]?
I know about the flag --no-warn-no-return but I do not want to mask other possible more dangerous events.
Actual Behavior
mypy generates error "Missing return statement" for both functions.
Your Environment
Mypy version used: 0.782
Mypy command-line flags: None
Mypy configuration options from mypy.ini - file is abcent.
Python version used: 3.8.5 64-bit
Operating system and version: Windows 10
The text was updated successfully, but these errors were encountered:
AndrewUshakov
changed the title
Possible false posititive "Missing return statement" if return type is Optional[int] etc.
Possible false positive "Missing return statement" if return type is Optional[int] etc.
Sep 1, 2020
I agree, that return None should exist in my second function according to PEP8:
"Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable):"
But mypy error disappears if add just a return at the end of my second function, which is insufficient according to PEP8. Of course, it is a different small issue (false negative).
🐛 Bug Report
mypy generates error "Missing return statement" for both functions
To Reproduce
Expected Behavior
in both cases errors can be eliminated by adding just a
return
orreturn None
at the end of both functions, but it is not really needed (does not change program behavior), because by default function without return statement at its end returns None which is a valid return value for Optional[]?I know about the flag --no-warn-no-return but I do not want to mask other possible more dangerous events.
Actual Behavior
mypy generates error "Missing return statement" for both functions.
Your Environment
mypy.ini
- file is abcent.The text was updated successfully, but these errors were encountered: