Skip to content

Commit 390388a

Browse files
committed
Ensure --strict-equality works correctly with partial types
1 parent 98abde4 commit 390388a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def accept_loop(
617617
# If necessary, reset the modified options and make up for the postponed error checks:
618618
if warn_redundant:
619619
self.options.enabled_error_codes.add(codes.REDUNDANT_EXPR)
620-
if self.options.warn_unreachable or warn_redundant:
620+
if self.options.warn_unreachable or warn_redundant or self.options.strict_equality:
621621
with self.binder.frame_context(can_skip=True, break_frame=2, continue_frame=1):
622622
if on_enter_body is not None:
623623
on_enter_body()

test-data/unit/check-errorcodes.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ if int() != str(): # E: Non-overlapping equality check (left operand type: "int
519519
pass
520520
if int() is str(): # E: Non-overlapping identity check (left operand type: "int", right operand type: "str") [comparison-overlap]
521521
pass
522+
523+
x = int()
524+
while True:
525+
if x is str(): # E: Non-overlapping identity check (left operand type: "int", right operand type: "str") [comparison-overlap]
526+
pass
522527
[builtins fixtures/primitives.pyi]
523528

524529
[case testErrorCodeMissingModule]

0 commit comments

Comments
 (0)