Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround parenthesised context manager issue #16949

Merged
merged 4 commits into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading