Skip to content

Commit 58c4ded

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

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

mypy/checkexpr.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,10 +2806,12 @@ 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)
2811-
else:
2809+
self.msg.disable_errors()
2810+
try:
28122811
right_type = self.analyze_cond_branch(right_map, e.right, left_type)
2812+
finally:
2813+
if right_map is None:
2814+
self.msg.enable_errors()
28132815

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

mypy/messages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ def disable_errors(self) -> Iterator[None]:
144144
yield
145145
finally:
146146
self.disable_count -= 1
147-
147+
148+
def enable_errors(self) -> None:
149+
self.disable_count -= 1
150+
148151
def is_errors(self) -> bool:
149152
return self.errors.is_errors()
150153

0 commit comments

Comments
 (0)