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

Separate pynames and pynamesdef and remove star-import #618

Merged
merged 2 commits into from
Dec 19, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions rope/base/pynames.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_definition_location(self):


class AssignedName(PyName):
"""Only a placeholder"""
pass


class UnboundName(PyName):
Expand Down Expand Up @@ -100,7 +100,7 @@ def invalidate(self):


class ParameterName(PyName):
"""Only a placeholder"""
pass


class ImportedModule(PyName):
Expand Down
28 changes: 26 additions & 2 deletions rope/base/pynamesdef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import rope.base.oi.soi
from rope.base import pynames
from rope.base.pynames import *
import rope.base.pyobjects
from rope.base import pynames, utils


class DefinedName(pynames.DefinedName):
pass


class AssignedName(pynames.AssignedName):
Expand Down Expand Up @@ -35,6 +39,10 @@ def invalidate(self):
self.pyobject.set(None)


class UnboundName(pynames.UnboundName):
pass


class ParameterName(pynames.ParameterName):
def __init__(self, pyfunction, index):
self.pyfunction = pyfunction
Expand All @@ -54,4 +62,20 @@ def get_definition_location(self):
return (self.pyfunction.get_module(), self.pyfunction.get_ast().lineno)


class AssignmentValue(pynames.AssignmentValue):
pass


class EvaluatedName(pynames.EvaluatedName):
pass


class ImportedModule(pynames.ImportedModule):
pass


class ImportedName(pynames.ImportedName):
pass


_Inferred = pynames._Inferred
10 changes: 5 additions & 5 deletions rope/base/pyobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,18 @@ def _create_scope(self):


class PyFunction(PyDefinedObject, AbstractFunction):
"""Only a placeholder"""
pass


class PyComprehension(PyDefinedObject, PyObject):
"""Only a placeholder"""
pass

def get_name(self):
return "<comprehension>"


class PyClass(PyDefinedObject, AbstractClass):
"""Only a placeholder"""
pass


class _ConcludedData:
Expand Down Expand Up @@ -317,11 +317,11 @@ def get_resource(self):


class PyModule(_PyModule):
"""Only a placeholder"""
pass


class PyPackage(_PyModule):
"""Only a placeholder"""
pass


class IsBeingInferredError(exceptions.RopeError):
Expand Down
11 changes: 8 additions & 3 deletions rope/refactor/occurrences.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from rope.base import evaluate
from rope.base import exceptions
from rope.base import pynames
from rope.base import pynamesdef
from rope.base import pyobjects
from rope.base import utils
from rope.base import worder
Expand Down Expand Up @@ -194,9 +195,13 @@ def same_pyname(expected, pyname):
return False
if expected == pyname:
return True
if type(expected) not in (pynames.ImportedModule, pynames.ImportedName) and type(
pyname
) not in (pynames.ImportedModule, pynames.ImportedName):
if not isinstance(
expected,
(pynames.ImportedModule, pynames.ImportedName),
) and not isinstance(
pyname,
(pynames.ImportedModule, pynames.ImportedName),
):
return False
return (
expected.get_definition_location() == pyname.get_definition_location()
Expand Down