Skip to content

Commit a83a570

Browse files
committed
Remove context manager from analyze_cond_branch call
1 parent db29355 commit a83a570

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

mypy/checkexpr.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,10 +2806,15 @@ def check_boolean_op(self, e: OpExpr, context: Context) -> Type:
28062806
left_map = None
28072807

28082808
if right_map is None:
2809-
with self.msg.disable_errors():
2810-
right_type = self.analyze_cond_branch(right_map, e.right, left_type)
2809+
self.msg.disable_errors1()
2810+
right_type = self.analyze_cond_branch(map=right_map,
2811+
node=e.right,
2812+
context=left_type)
2813+
self.msg.enable_errors()
28112814
else:
2812-
right_type = self.analyze_cond_branch(right_map, e.right, left_type)
2815+
right_type = self.analyze_cond_branch(map=right_map,
2816+
node=e.right,
2817+
context=left_type)
28132818

28142819
if right_map is None:
28152820
# The boolean expression is statically known to be the left value

mypy/messages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def add_errors(self, messages: 'MessageBuilder') -> None:
137137
for info in errs:
138138
self.errors.add_error_info(info)
139139

140+
def disable_errors1(self) -> None:
141+
self.disable_count += 1
142+
140143
@contextmanager
141144
def disable_errors(self) -> Iterator[None]:
142145
self.disable_count += 1
@@ -145,6 +148,9 @@ def disable_errors(self) -> Iterator[None]:
145148
finally:
146149
self.disable_count -= 1
147150

151+
def enable_errors(self) -> None:
152+
self.disable_count -= 1
153+
148154
def is_errors(self) -> bool:
149155
return self.errors.is_errors()
150156

0 commit comments

Comments
 (0)