Skip to content

Commit

Permalink
Remove unicode->str type aliasing
Browse files Browse the repository at this point in the history
unicode was a relic of Python 2 transition. rope no longer support
Python 2, so this is no longer needed.
  • Loading branch information
lieryan committed Nov 25, 2022
1 parent 8223e45 commit 339a99c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
7 changes: 1 addition & 6 deletions rope/base/ast.py
Expand Up @@ -3,15 +3,10 @@

from rope.base import fscommands

try:
unicode
except NameError:
unicode = str


def parse(source, filename="<string>"):
# NOTE: the raw string should be given to `compile` function
if isinstance(source, unicode):
if isinstance(source, str):
source = fscommands.unicode_to_file_data(source)
if b"\r" in source:
source = source.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
Expand Down
6 changes: 1 addition & 5 deletions rope/base/fscommands.py
Expand Up @@ -14,10 +14,6 @@
import rope.base.utils.pycompat as pycompat
import typing

try:
unicode
except NameError:
unicode = str

FileContent = typing.NewType("FileContent", bytes)

Expand Down Expand Up @@ -244,7 +240,7 @@ def file_data_to_unicode(data, encoding=None):


def _decode_data(data, encoding):
if isinstance(data, unicode):
if isinstance(data, str):
return data
if encoding is None:
encoding = read_str_coding(data)
Expand Down
7 changes: 1 addition & 6 deletions rope/base/pyobjectsdef.py
Expand Up @@ -17,11 +17,6 @@
)
from rope.base.utils import pycompat

try:
unicode
except NameError:
unicode = str


class PyFunction(pyobjects.PyFunction):
def __init__(self, pycore, ast_node, parent):
Expand Down Expand Up @@ -204,7 +199,7 @@ def _init_source(self, pycore, source_code, resource):
source_bytes = resource.read_bytes()
source_code, _ = fscommands.file_data_to_unicode(source_bytes)
else:
if isinstance(source_code, unicode):
if isinstance(source_code, str):
source_bytes = fscommands.unicode_to_file_data(source_code)
else:
source_bytes = source_code
Expand Down
9 changes: 2 additions & 7 deletions ropetest/contrib/codeassisttest.py
Expand Up @@ -16,11 +16,6 @@
)
from ropetest import testutils

try:
unicode
except NameError:
unicode = str


class CodeAssistTest(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -731,7 +726,7 @@ def test_get_pydoc_unicode(self):
def foo():
u"юникод-объект"''')
doc = get_doc(self.project, src, src.index("foo") + 1)
self.assertTrue(isinstance(doc, unicode))
self.assertTrue(isinstance(doc, str))
self.assertTrue("юникод-объект" in doc)

def test_get_pydoc_utf8_bytestring(self):
Expand All @@ -740,7 +735,7 @@ def test_get_pydoc_utf8_bytestring(self):
def foo():
"байтстринг"''')
doc = get_doc(self.project, src, src.index("foo") + 1)
self.assertTrue(isinstance(doc, unicode))
self.assertTrue(isinstance(doc, str))
self.assertTrue("байтстринг" in doc)

def test_get_pydoc_for_functions(self):
Expand Down

0 comments on commit 339a99c

Please sign in to comment.