We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdac0c4 commit e9cc4b2Copy full SHA for e9cc4b2
mypy/checker.py
@@ -5732,6 +5732,16 @@ def get_expr_name() -> str:
5732
self.fail(message_registry.TYPE_ALWAYS_TRUE.format(format_expr_type()), expr)
5733
5734
def check_for_optional_non_truthy_type(self, t: Type, expr: Expression) -> None:
5735
+ """Check if a type involves both None and types that aren't always true, catching
5736
+ suspicious cases of falsy values being lumped together with None.
5737
+
5738
+ Used in checks like::
5739
5740
+ if x: # <---
5741
5742
+ not x # <---
5743
5744
+ """
5745
t = get_proper_type(t)
5746
if not isinstance(t, UnionType):
5747
return # not a Optional or Union at all
0 commit comments