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
{{ message }}
Repository navigation
Non-overlapping identity check when left operand is not optional and right operand is None #11888
It was decided when --strict-equality was implemented that (according to #6370) "X and None are overlapping even in strict-optional mode".
Current documentation reads:
* X and None are overlapping even in strict-optional mode. This is to allow
'assert x is not None' for x defined as 'x = None # type: str' in class body
(otherwise mypy itself would have couple dozen errors because of this).
As chnmasta05 mentions, this is intentional in --strict-equality not warning on the comparison.
Note --warn-unreachable will warn about the dead code in your if block.
Activity
chnmasta05 commentedon May 31, 2023
I suggest adding the
topic-overlaplabel.It was decided when --strict-equality was implemented that (according to #6370) "X and None are overlapping even in strict-optional mode".
Current documentation reads:
gschaffner commentedon Nov 24, 2025
Is this the same as #18386?
hauntsaninja commentedon Oct 21, 2026
As chnmasta05 mentions, this is intentional in
--strict-equalitynot warning on the comparison.Note
--warn-unreachablewill warn about the dead code in your if block.