Skip to content

Commit edf63d7

Browse files
committed
respect that other error watcher may want to filter comparison-overlap errors
1 parent 2182e5d commit edf63d7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mypy/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,8 @@ def dangerous_comparison(self, left: Type, right: Type, kind: str, ctx: Context)
16321632
# respective types of the current iteration here so that we can report the error
16331633
# later if it is persistent over all iteration steps:
16341634
for watcher in self.errors.get_watchers():
1635+
if watcher._filter:
1636+
return
16351637
if isinstance(watcher, IterationErrorWatcher):
16361638
watcher.iteration_dependent_errors.nonoverlapping_types[-1][
16371639
(ctx.line, ctx.column, ctx.end_line, ctx.end_column, kind)

test-data/unit/check-narrowing.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ while True:
24762476
# flags: --strict-equality
24772477

24782478
for y in [1.0]:
2479-
if y is not None or y != "None": # E: Non-overlapping equality check (left operand type: "float", right operand type: "Literal['None']")
2479+
if y is not None or y != "None":
24802480
...
24812481

24822482
[builtins fixtures/primitives.pyi]

0 commit comments

Comments
 (0)