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
When encountering an error due to using a comparison operator with None as one of the arguments, Mypy adjusts the direction of < and > operators in its messages based on the types involved so that it always reports None as the second type (e.g. Unsupported operand types for {comparisson operator direction} ("int" and "None")). This becomes increasingly confusing when both variables in the comparison could potentially be a large number of types.
To reproduce
For the following code
1<None1>NoneNone<1None>1
Expected Behavior
file.py:1: error: Unsupported operand types for < ("int" and "None") [operator]
file.py:2: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:3: error: Unsupported operand types for < ("None" and "int") [operator]
file.py:4: error: Unsupported operand types for > ("None" and "int") [operator]
Actual Behavior
file.py:1: error: Unsupported operand types for < ("int" and "None") [operator]
file.py:2: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:3: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:4: error: Unsupported operand types for < ("int" and "None") [operator]
Your Environment
Mypy version used: 1.10
Python version used: 3.12
The text was updated successfully, but these errors were encountered:
Bug Report
When encountering an error due to using a comparison operator with None as one of the arguments, Mypy adjusts the direction of
<
and>
operators in its messages based on the types involved so that it always reportsNone
as the second type (e.g.Unsupported operand types for
{comparisson operator direction}
("int" and "None")
). This becomes increasingly confusing when both variables in the comparison could potentially be a large number of types.To reproduce
For the following code
Expected Behavior
Actual Behavior
Your Environment
The text was updated successfully, but these errors were encountered: