Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated libcst dependency #66

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.