Skip to content

Commit

Permalink
Updated libcst dependency
Browse files Browse the repository at this point in the history
- Small refactor in NameResolutionMixin
  • Loading branch information
andrecsilva committed Oct 9, 2023
1 parent f65f1f6 commit 0603723
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 55 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ license = {file = "LICENSE"}
dependencies = [
"dependency-manager @ git+https://github.com/pixee/python-dependency-manager#egg=dependency-manager",
"isort~=5.12.0",
# Temp fix until the next release of libcst
"libcst @ git+https://github.com/Instagram/LibCST.git@03179b55ebe7e916f1722e18e8f0b87c01616d1f",
"libcst~=1.1.0",
"pylint~=3.0.0",
"PyYAML~=6.0.0",
"semgrep~=1.43.0",
Expand Down
6 changes: 3 additions & 3 deletions src/codemodder/codemods/utils_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import libcst as cst
from libcst import MetadataDependent, matchers
from libcst.helpers import get_full_name_for_node
from libcst.metadata import Assignment, ImportAssignment, ScopeProvider
from libcst.metadata import Assignment, BaseAssignment, ImportAssignment, ScopeProvider


class NameResolutionMixin(MetadataDependent):
Expand Down Expand Up @@ -60,14 +60,14 @@ def _is_direct_call_from_imported_module(
def find_assignments(
self,
node: Union[cst.Name, cst.Attribute, cst.Call, cst.Subscript, cst.Decorator],
) -> set[Assignment]:
) -> set[BaseAssignment]:
"""
Given a MetadataWrapper and a CSTNode with a possible access to it, find all the possible assignments that it refers.
"""
scope = self.get_metadata(ScopeProvider, node)
if node in scope.accesses:
# pylint: disable=protected-access
return next(iter(scope.accesses[node]))._Access__assignments
return set(next(iter(scope.accesses[node])).referents)
return set()

def find_single_assignment(
Expand Down
50 changes: 0 additions & 50 deletions tests/transformations/test_add_imports.py

This file was deleted.

0 comments on commit 0603723

Please sign in to comment.