Skip to content

Commit

Permalink
fixup! Change _get_assign_nodes() to cached_property
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Mar 12, 2023
1 parent 8e463b2 commit 7dcc3f1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions astroid/nodes/_base_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def _get_yield_nodes_skip_lambdas(self):
yield from child_node._get_yield_nodes_skip_lambdas()

@cached_property
def _get_assign_nodes(self):
def _assign_nodes_in_scope(self) -> list[nodes.Assign]:
children_assign_nodes = (
child_node._get_assign_nodes
child_node._assign_nodes_in_scope
for block in self._multi_line_blocks
for child_node in block
)
Expand Down
4 changes: 2 additions & 2 deletions astroid/nodes/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ def get_children(self):
yield self.value

@cached_property
def _get_assign_nodes(self):
return [self] + self.value._get_assign_nodes
def _assign_nodes_in_scope(self) -> list[nodes.Assign]:
return [self] + self.value._assign_nodes_in_scope

def _get_yield_nodes_skip_lambdas(self):
yield from self.value._get_yield_nodes_skip_lambdas()
Expand Down
2 changes: 1 addition & 1 deletion astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def nodes_of_class( # type: ignore[misc] # mypy doesn't correctly recognize the
yield from child_node.nodes_of_class(klass, skip_klass)

@cached_property
def _get_assign_nodes(self):
def _assign_nodes_in_scope(self) -> list[nodes.Assign]:
return []

def _get_name_nodes(self):
Expand Down
6 changes: 3 additions & 3 deletions astroid/nodes/scoped_nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ def extra_decorators(self) -> list[node_classes.Call]:
return []

decorators: list[node_classes.Call] = []
for assign in frame._get_assign_nodes:
for assign in frame._assign_nodes_in_scope:
if isinstance(assign.value, node_classes.Call) and isinstance(
assign.value.func, node_classes.Name
):
Expand Down Expand Up @@ -3067,9 +3067,9 @@ def get_children(self):
yield from self.body

@cached_property
def _get_assign_nodes(self):
def _assign_nodes_in_scope(self):
children_assign_nodes = (
child_node._get_assign_nodes for child_node in self.body
child_node._assign_nodes_in_scope for child_node in self.body
)
return list(itertools.chain.from_iterable(children_assign_nodes))

Expand Down

0 comments on commit 7dcc3f1

Please sign in to comment.