Skip to content

Commit e9cc4b2

Browse files
committed
Doc string
1 parent fdac0c4 commit e9cc4b2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mypy/checker.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5732,6 +5732,16 @@ def get_expr_name() -> str:
57325732
self.fail(message_registry.TYPE_ALWAYS_TRUE.format(format_expr_type()), expr)
57335733

57345734
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+
"""
57355745
t = get_proper_type(t)
57365746
if not isinstance(t, UnionType):
57375747
return # not a Optional or Union at all

0 commit comments

Comments
 (0)