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
Copy file name to clipboardExpand all lines: docs/source/error_code_list2.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -392,7 +392,7 @@ values should indeed behave like `None`.
392
392
# Use "mypy --enable-error-code optional-non-truthy ..."
393
393
394
394
foo: None|int=0
395
-
# Error: FIXME
395
+
# Error: "foo" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
"{} where both None and some other values (of {}: {}) may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values.",
172
+
code=codes.OPTIONAL_NON_TRUTHY,
173
+
)
171
174
NOT_CALLABLE: Final="{} not callable"
172
175
TYPE_MUST_BE_USED: Final="Value of type {} must be used"
if var: # E: "var" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
973
973
...
974
974
975
-
not var # E: FIXME x [optional-non-truthy]
975
+
not var # E: "var" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
976
976
977
977
def error_bool(var: None | bool) -> None:
978
-
if var: # E: FIXME x [optional-non-truthy]
978
+
if var: # E: "var" has type "Optional[bool]" where both None and some other values (of type: "bool") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
979
979
...
980
980
981
-
not var # E: FIXME x [optional-non-truthy]
981
+
not var # E: "var" has type "Optional[bool]" where both None and some other values (of type: "bool") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
982
982
983
983
def error_list(var: None | list[Truthy]) -> None:
984
-
if var: # E: FIXME x [optional-non-truthy]
984
+
if var: # E: "var" has type "Optional[List[Truthy]]" where both None and some other values (of type: "List[Truthy]") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
985
985
...
986
986
987
-
not var # E: FIXME x [optional-non-truthy]
987
+
not var # E: "var" has type "Optional[List[Truthy]]" where both None and some other values (of type: "List[Truthy]") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
if var: # E: "var" has type "Optional[NonTruthy]" where both None and some other values (of type: "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
991
991
...
992
992
993
-
not var # E: FIXME x [optional-non-truthy]
993
+
not var # E: "var" has type "Optional[NonTruthy]" where both None and some other values (of type: "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
if var: # E: "var" has type "Union[int, Truthy, NonTruthy, None]" where both None and some other values (of types: "int", "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
997
997
...
998
998
999
-
not var # E: FIXME x [optional-non-truthy]
999
+
not var # E: "var" has type "Union[int, Truthy, NonTruthy, None]" where both None and some other values (of types: "int", "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
if var: # E: "var" has type "Optional[Unconstrained]" where both None and some other values (of type: "Unconstrained") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
1005
1005
...
1006
1006
1007
-
not var # E: FIXME x [optional-non-truthy]
1007
+
not var # E: "var" has type "Optional[Unconstrained]" where both None and some other values (of type: "Unconstrained") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
if var: # E: "var" has type "Optional[str]" where both None and some other values (of type: "str") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy] \
1013
+
# E: "var" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy] \
1014
+
# E: "var" has type "Optional[NonTruthy]" where both None and some other values (of type: "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
1013
1015
...
1014
1016
1015
-
not var # E: FIXME x [optional-non-truthy]
1017
+
not var # E: "var" has type "Optional[str]" where both None and some other values (of type: "str") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy] \
1018
+
# E: "var" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy] \
1019
+
# E: "var" has type "Optional[NonTruthy]" where both None and some other values (of type: "NonTruthy") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
0 commit comments