Skip to content

Commit

Permalink
Fix scope count for nested classes.
Browse files Browse the repository at this point in the history
This was triggering negative number of class scopes,
and not allowing proper scoping of type annotations in class
definitions.

It is still weird that this work before unhiding the class scope, but I
guess as we are in Function Scope this is going to be a delayed
evaluation of the scope.
  • Loading branch information
Carreau committed Mar 18, 2024
1 parent a347508 commit 8265e17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/python/pyflyby/_autoimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ def visit_ClassDef(self, node):
if self._in_class_def == 0:
self.scopestack._class_delayed[node.name] = None
with self._NewScopeCtx(new_class_scope=True):
if not self._in_class_def:
self._in_class_def += 1
self._visit_Store(node.name)
self._in_class_def += 1
self._visit_Store(node.name)
self.visit(node.body)
self._in_class_def -= 1
assert self._in_class_def >= 0
self._remove_from_missing_imports(node.name)
self._visit_Store(node.name)

Expand Down

0 comments on commit 8265e17

Please sign in to comment.