Skip to content

Commit c50e9f9

Browse files
authored
Remove pushing of state onto nodes stack (#466)
Vestigial from pyupgrade skeleton.
1 parent 40c275e commit c50e9f9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/django_upgrade/data.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,17 @@ def visit(
117117
settings: Settings,
118118
filename: str,
119119
) -> dict[Offset, list[TokenFunc]]:
120-
initial_state = State(
120+
state = State(
121121
settings=settings,
122122
filename=filename,
123123
from_imports=defaultdict(set),
124124
)
125-
ast_funcs = get_ast_funcs(initial_state, settings)
125+
ast_funcs = get_ast_funcs(state, settings)
126126

127-
nodes: list[tuple[State, ast.AST, tuple[ast.AST, ...]]] = [
128-
(initial_state, tree, ())
129-
]
127+
nodes: list[tuple[ast.AST, tuple[ast.AST, ...]]] = [(tree, ())]
130128
ret = defaultdict(list)
131129
while nodes:
132-
state, node, parents = nodes.pop()
130+
node, parents = nodes.pop()
133131

134132
for ast_func in ast_funcs[type(node)]:
135133
for offset, token_func in ast_func(state, node, parents):
@@ -152,14 +150,13 @@ def visit(
152150
subparents = parents + (node,)
153151
for name in reversed(node._fields):
154152
value = getattr(node, name)
155-
next_state = state
156153

157154
if isinstance(value, ast.AST):
158-
nodes.append((next_state, value, subparents))
155+
nodes.append((value, subparents))
159156
elif isinstance(value, list):
160157
for subvalue in reversed(value):
161158
if isinstance(subvalue, ast.AST):
162-
nodes.append((next_state, subvalue, subparents))
159+
nodes.append((subvalue, subparents))
163160
return ret
164161

165162

0 commit comments

Comments
 (0)