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
def test(a: int | None, b: int | None) -> int | None:
if any(x is None for x in [a, b]):
return None
return a+b
and this function:
def test_2(a: int | None, b: int | None) -> int | None:
if a is None or b is None:
return None
return a+b
do the same thing. However, for the first one, mpy produces an error:
test.py:8: error: Unsupported operand types for + ("int" and "None") [operator]
test.py:8: error: Unsupported operand types for + ("None" and "int") [operator]
test.py:8: error: Unsupported left operand type for + ("None") [operator]
while for the second one, the fact that a and b are not None is inferred correctly.
It would be great to improve the inference for this case!
The text was updated successfully, but these errors were encountered:
This function:
and this function:
do the same thing. However, for the first one, mpy produces an error:
while for the second one, the fact that a and b are not None is inferred correctly.
It would be great to improve the inference for this case!
The text was updated successfully, but these errors were encountered: