Skip to content

Commit

Permalink
Workaround parenthesised context manager issue (#16949)
Browse files Browse the repository at this point in the history
Fixes #16945
  • Loading branch information
hauntsaninja committed Feb 25, 2024
1 parent 790e8a7 commit 2037e4a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import itertools
from collections import defaultdict
from contextlib import contextmanager, nullcontext
from contextlib import ExitStack, contextmanager
from typing import (
AbstractSet,
Callable,
Expand Down Expand Up @@ -526,17 +526,11 @@ def check_second_pass(
# print("XXX in pass %d, class %s, function %s" %
# (self.pass_num, type_name, node.fullname or node.name))
done.add(node)
with (
self.tscope.class_scope(active_typeinfo)
if active_typeinfo
else nullcontext()
):
with (
self.scope.push_class(active_typeinfo)
if active_typeinfo
else nullcontext()
):
self.check_partial(node)
with ExitStack() as stack:
if active_typeinfo:
stack.enter_context(self.tscope.class_scope(active_typeinfo))
stack.enter_context(self.scope.push_class(active_typeinfo))
self.check_partial(node)
return True

def check_partial(self, node: DeferredNodeType | FineGrainedDeferredNodeType) -> None:
Expand Down

0 comments on commit 2037e4a

Please sign in to comment.