Skip to content

Commit e98f4be

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1498e83 commit e98f4be

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

mypy/semanal.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,9 +2110,7 @@ def analyze_class_body_common(self, defn: ClassDef) -> None:
21102110
# Pre-scan class body to find names assigned at class scope level.
21112111
# This must happen after enter_class (which pushes an empty set) so we
21122112
# can replace it with the real set.
2113-
self.class_body_assigned_names[-1] = collect_class_body_assigned_names(
2114-
defn.defs.body
2115-
)
2113+
self.class_body_assigned_names[-1] = collect_class_body_assigned_names(defn.defs.body)
21162114
if any(b.self_type is not None for b in defn.info.mro):
21172115
self.setup_self_type()
21182116
defn.defs.accept(self)
@@ -8396,7 +8394,7 @@ def collect_class_body_assigned_names(stmts: list[Statement]) -> set[str]:
83968394
This mirrors CPython's compile-time analysis that determines whether a name
83978395
in a class body is accessed via LOAD_NAME (class dict -> globals -> builtins)
83988396
or LOAD_CLASSDEREF or LOAD_FROM_DICT_OR_DEREF (class dict -> enclosing function cell).
8399-
8397+
84008398
Names that are assigned anywhere in the class body (even inside if/for/while/try/with blocks)
84018399
use LOAD_NAME, so they should NOT be resolved from enclosing function locals.
84028400

0 commit comments

Comments
 (0)