Skip to content

Commit

Permalink
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 91fd7b9 commit 8e463b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions astroid/nodes/_base_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from collections.abc import Iterator
from typing import TYPE_CHECKING, ClassVar

from astroid import decorators
from astroid.exceptions import AttributeInferenceError
from astroid.nodes.node_ng import NodeNG

Expand Down Expand Up @@ -196,10 +195,10 @@ def _get_yield_nodes_skip_lambdas(self):
continue
yield from child_node._get_yield_nodes_skip_lambdas()

@decorators.cached
@cached_property
def _get_assign_nodes(self):
children_assign_nodes = (
child_node._get_assign_nodes()
child_node._get_assign_nodes
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 @@ -1271,9 +1271,9 @@ def get_children(self):

yield self.value

@decorators.cached
@cached_property
def _get_assign_nodes(self):
return [self] + list(self.value._get_assign_nodes())
return [self] + self.value._get_assign_nodes

def _get_yield_nodes_skip_lambdas(self):
yield from self.value._get_yield_nodes_skip_lambdas()
Expand Down
4 changes: 2 additions & 2 deletions astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
overload,
)

from astroid import decorators, util
from astroid import util
from astroid.context import InferenceContext
from astroid.exceptions import (
AstroidError,
Expand Down Expand Up @@ -575,7 +575,7 @@ def nodes_of_class( # type: ignore[misc] # mypy doesn't correctly recognize the
continue
yield from child_node.nodes_of_class(klass, skip_klass)

@decorators.cached
@cached_property
def _get_assign_nodes(self):
return []

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._get_assign_nodes:
if isinstance(assign.value, node_classes.Call) and isinstance(
assign.value.func, node_classes.Name
):
Expand Down Expand Up @@ -3066,10 +3066,10 @@ def get_children(self):
yield from self.keywords
yield from self.body

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

Expand Down

0 comments on commit 8e463b2

Please sign in to comment.