Skip to content

Commit

Permalink
Remove basestring
Browse files Browse the repository at this point in the history
This was legacy python2-ism
  • Loading branch information
lieryan committed Dec 1, 2022
1 parent 39c6c56 commit 4ae5d41
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 2 additions & 3 deletions rope/refactor/patchedast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from rope.base import ast, codeanalyze, exceptions

basestring = (str, bytes)

COMMA_IN_WITH_PATTERN = re.compile(r"\(.*?\)|(,)")

Expand Down Expand Up @@ -217,7 +216,7 @@ def _count_needed_parens(self, children):
start = 0
opens = 0
for child in children:
if not isinstance(child, basestring):
if not isinstance(child, (str, bytes)):
continue
if child == "" or child[0] in "'\"":
continue
Expand Down Expand Up @@ -379,7 +378,7 @@ def _Delete(self, node):
self._handle(node, ["del"] + self._child_nodes(node.targets, ","))

def _Constant(self, node):
if isinstance(node.value, basestring):
if isinstance(node.value, (str, bytes)):
self._handle(node, [self.String])
return

Expand Down
6 changes: 1 addition & 5 deletions ropetest/refactor/patchedasttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
from rope.refactor import patchedast
from ropetest import testutils

try:
basestring
except NameError:
basestring = (str, bytes)

NameConstant = "Name" if sys.version_info <= (3, 8) else "NameConstant"
Bytes = "Bytes" if (3, 0) <= sys.version_info <= (3, 8) else "Str"
Expand Down Expand Up @@ -1670,7 +1666,7 @@ def check_children(self, text, children):
if not isinstance(expected, (tuple, list)):
goals = [expected]
for goal in goals:
if goal == "" or isinstance(child, basestring):
if goal == "" or isinstance(child, (str, bytes)):
self.test_case.assertEqual(goal, child)
break
else:
Expand Down

0 comments on commit 4ae5d41

Please sign in to comment.