Skip to content

Commit

Permalink
Merge pull request #618 from python-rope/lieryan-pyobjects
Browse files Browse the repository at this point in the history
Removing star-import
  • Loading branch information
lieryan committed Dec 19, 2022
2 parents 7e43238 + e3c684f commit d6ea864
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
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

0 comments on commit d6ea864

Please sign in to comment.