Skip to content

Commit

Permalink
Fixed a bug with assignment detection
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Jan 3, 2024
1 parent ec6e660 commit 313e236
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/codemodder/codemods/utils_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def find_global_scope(self):
def find_single_assignment(
self,
node: Union[cst.Name, cst.Attribute, cst.Call, cst.Subscript, cst.Decorator],
) -> Optional[Assignment]:
) -> Optional[BaseAssignment]:
"""
Given a MetadataWrapper and a CSTNode representing an access, find if there is a single assignment that it refers to.
"""
Expand Down Expand Up @@ -395,7 +395,7 @@ def resolve_expression(self, node: cst.BaseExpression) -> cst.BaseExpression:

def _resolve_name_transitive(self, node: cst.Name) -> Optional[cst.BaseExpression]:
maybe_assignment = self.find_single_assignment(node)
if maybe_assignment:
if maybe_assignment and isinstance(maybe_assignment, Assignment):
if maybe_target_assignment := self.is_target_of_assignment(
maybe_assignment.node
):
Expand Down

0 comments on commit 313e236

Please sign in to comment.