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
Without --strict-optional, some invalid None opertations are undetected:
None + 1 # ok
None * 1 # ok
None / 1 # ok
None - 1 # ok
None + '' # error
None * '' # ok
None / '' # error
None - '' # error
With --strict-optional, all of them fail type check but with inconsistent error messages:
Unsupported operand types for + (None and "int")
Unsupported operand types for * (None and "int")
Unsupported operand types for / (None and "int")
Unsupported operand types for - (None and "int")
Unsupported left operand type for + (None)
Unsupported operand types for * (None and "str")
Unsupported left operand type for / (None)
Unsupported left operand type for - (None)
The text was updated successfully, but these errors were encountered:
The plan is to make --strict-optional turned on by default, so that the first part does not need to be fixed. However, the error messages could be more homogeneous indeed.
Then I guess we should fix a few tests because everyone likes to put None + 1 as an example of what should fail (like in testTypeCheckNamedModule2, testMypyConditional, etc.). Or are we going to start running tests with --strict-optional in the next few days?
(Based on #3111)
Without
--strict-optional
, some invalidNone
opertations are undetected:With
--strict-optional
, all of them fail type check but with inconsistent error messages:The text was updated successfully, but these errors were encountered: