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
from typing import Optional
# mypy is OK with this function,
def allowed(foo: Optional[int]) -> None:
if foo is not None:
foo + 0
# but it's not OK with this one.
def disallowed(foo: Optional[int]) -> None:
try:
foo + 0
except TypeError:
pass
To Reproduce
Create a file called bug_triggering_code.py.
Copy the above example code.
Paste the code into bug_triggering_code.py.
Run mypy bug_triggering_code.py.
Expected Behavior
mypy reports no errors. Even if mypy does report errors, it should report that both functions have errors.
Actual Behavior
mypy reports an error for the disallowed() function but not for the allowed() function: bug_triggering_code.py:13: error: Unsupported operand types for + ("None" and "int")
Your Environment
Mypy version used: 0.790
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): I have no config files.
Python version used: 3.8.6
Operating system and version: Arch Linux. I'm not sure how I would give a version for this.
The text was updated successfully, but these errors were encountered:
Bug Report
To Reproduce
bug_triggering_code.py
.bug_triggering_code.py
.mypy bug_triggering_code.py
.Expected Behavior
mypy reports no errors. Even if mypy does report errors, it should report that both functions have errors.
Actual Behavior
mypy reports an error for the
disallowed()
function but not for theallowed()
function:bug_triggering_code.py:13: error: Unsupported operand types for + ("None" and "int")
Your Environment
mypy.ini
(and other config files): I have no config files.The text was updated successfully, but these errors were encountered: