Skip to content

Commit

Permalink
use pyupgrade to bump to python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
bagel897 authored and lieryan committed May 24, 2022
1 parent b9739fd commit 73d8db3
Show file tree
Hide file tree
Showing 70 changed files with 311 additions and 319 deletions.
6 changes: 3 additions & 3 deletions rope/base/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rope.base import ast


class Arguments(object):
class Arguments:
"""A class for evaluating parameters passed to a function
You can use the `create_arguments` factory. It handles implicit
Expand Down Expand Up @@ -52,7 +52,7 @@ def create_arguments(primary, pyfunction, call_node, scope):
return Arguments(args, scope)


class ObjectArguments(object):
class ObjectArguments:
def __init__(self, pynames):
self.pynames = pynames

Expand All @@ -72,7 +72,7 @@ def get_instance_pyname(self):
return self.pynames[0]


class MixedArguments(object):
class MixedArguments:
def __init__(self, pyname, arguments, scope):
"""`argumens` is an instance of `Arguments`"""
self.pyname = pyname
Expand Down
1 change: 0 additions & 1 deletion rope/base/ast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import ast
from ast import *

Expand Down
2 changes: 1 addition & 1 deletion rope/base/astutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_name_levels(node):
return visitor.names


class _NodeNameCollector(object):
class _NodeNameCollector:
def __init__(self, levels=None):
self.names = []
self.levels = levels
Expand Down
34 changes: 17 additions & 17 deletions rope/base/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class BuiltinModule(pyobjects.AbstractModule):
def __init__(self, name, pycore=None, initial={}):
super(BuiltinModule, self).__init__()
super().__init__()
self.name = name
self.pycore = pycore
self.initial = initial
Expand Down Expand Up @@ -54,7 +54,7 @@ def module(self):
return


class _BuiltinElement(object):
class _BuiltinElement:
def __init__(self, builtin, parent=None):
self.builtin = builtin
self._parent = parent
Expand Down Expand Up @@ -112,7 +112,7 @@ def get_param_names(self, special_args=True):

class BuiltinUnknown(_BuiltinElement, pyobjects.PyObject):
def __init__(self, builtin):
super(BuiltinUnknown, self).__init__(pyobjects.get_unknown())
super().__init__(pyobjects.get_unknown())
self.builtin = builtin
self.type = pyobjects.get_unknown()

Expand Down Expand Up @@ -166,7 +166,7 @@ def _get_builtin(*args):
return _get_builtin


class _CallContext(object):
class _CallContext:
def __init__(self, argnames, args):
self.argnames = argnames
self.args = args
Expand Down Expand Up @@ -229,7 +229,7 @@ def save_per_name(self, value):
pymodule.pycore.object_info.save_per_name(scope, name, value)


class _AttributeCollector(object):
class _AttributeCollector:
def __init__(self, type):
self.attributes = {}
self.type = type
Expand Down Expand Up @@ -302,7 +302,7 @@ def __init__(self, holding=None):
except AttributeError:
pass

super(List, self).__init__(list, collector.attributes)
super().__init__(list, collector.attributes)

def _new_list(self, args):
return _create_builtin(args, get_list)
Expand Down Expand Up @@ -362,7 +362,7 @@ def __init__(self, keys=None, values=None):
collector("__getitem__", function=self._value_get, parent=self)
collector("__iter__", function=self._key_iter, parent=self)
collector("update", function=self._self_set, parent=self)
super(Dict, self).__init__(dict, collector.attributes)
super().__init__(dict, collector.attributes)

def _new_dict(self, args):
def do_create(holding=None):
Expand Down Expand Up @@ -454,7 +454,7 @@ def __init__(self, *objects):
"__new__": BuiltinName(BuiltinFunction(function=self._new_tuple)),
"__iter__": BuiltinName(BuiltinFunction(get_iterator(first))),
}
super(Tuple, self).__init__(tuple, attributes)
super().__init__(tuple, attributes)

def get_holding_objects(self):
return self.objects
Expand Down Expand Up @@ -490,7 +490,7 @@ def __init__(self, holding=None):

collector("pop", function=self._set_get, parent=self)
collector("__iter__", function=self._iterator_get, parent=self)
super(Set, self).__init__(set, collector.attributes)
super().__init__(set, collector.attributes)

def _new_set(self, args):
return _create_builtin(args, get_set)
Expand Down Expand Up @@ -565,7 +565,7 @@ def __init__(self):
for method in ["rsplit", "split", "splitlines"]:
collector(method, get_list(self_object), parent=self)

super(Str, self).__init__(str, collector.attributes)
super().__init__(str, collector.attributes)

def get_doc(self):
return str.__doc__
Expand All @@ -588,7 +588,7 @@ def get_definition_location(self):

class Iterator(pyobjects.AbstractClass):
def __init__(self, holding=None):
super(Iterator, self).__init__()
super().__init__()
self.holding = holding
self.attributes = {
"next": BuiltinName(BuiltinFunction(self.holding)),
Expand All @@ -607,7 +607,7 @@ def get_returned_object(self, args):

class Generator(pyobjects.AbstractClass):
def __init__(self, holding=None):
super(Generator, self).__init__()
super().__init__()
self.holding = holding
self.attributes = {
"next": BuiltinName(BuiltinFunction(self.holding)),
Expand Down Expand Up @@ -658,7 +658,7 @@ def add(name, returned=None, function=None):
"writelines",
]:
add(method)
super(File, self).__init__(open, attributes)
super().__init__(open, attributes)


get_file = _create_builtin_getter(File)
Expand All @@ -675,7 +675,7 @@ def __init__(self, fget=None, fset=None, fdel=None, fdoc=None):
"fdel": BuiltinName(pynames.UnboundName()),
"__new__": BuiltinName(BuiltinFunction(function=_property_function)),
}
super(Property, self).__init__(property, attributes)
super().__init__(property, attributes)

def get_property_object(self, args):
if isinstance(self._fget, pyobjects.AbstractFunction):
Expand All @@ -689,7 +689,7 @@ def _property_function(args):

class Lambda(pyobjects.AbstractFunction):
def __init__(self, node, scope):
super(Lambda, self).__init__()
super().__init__()
self.node = node
self.arguments = node.args
self.scope = scope
Expand Down Expand Up @@ -738,12 +738,12 @@ def parent(self):

class BuiltinObject(BuiltinClass):
def __init__(self):
super(BuiltinObject, self).__init__(object, {})
super().__init__(object, {})


class BuiltinType(BuiltinClass):
def __init__(self):
super(BuiltinType, self).__init__(type, {})
super().__init__(type, {})


def _infer_sequence_for_pyname(pyname):
Expand Down
18 changes: 9 additions & 9 deletions rope/base/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rope.base import taskhandle, exceptions, utils


class Change(object):
class Change:
"""The base class for changes
Rope refactorings return `Change` objects. They can be previewed,
Expand Down Expand Up @@ -103,7 +103,7 @@ def __str__(self):
else:
string_date = date.strftime("%d %b, %Y")
string_time = date.strftime("%H:%M:%S")
string_time = "%s %s " % (string_date, string_time)
string_time = "{} {} ".format(string_date, string_time)
return self.description + " - " + string_time
return self.description

Expand Down Expand Up @@ -211,7 +211,7 @@ def __str__(self):
return "Move <%s>" % self.resource.path

def get_description(self):
return "rename from %s\nrename to %s" % (
return "rename from {}\nrename to {}".format(
self.resource.path,
self.new_resource.path,
)
Expand Down Expand Up @@ -263,7 +263,7 @@ class CreateFolder(CreateResource):

def __init__(self, parent, name):
resource = parent.project.get_folder(self._get_child_path(parent, name))
super(CreateFolder, self).__init__(resource)
super().__init__(resource)


class CreateFile(CreateResource):
Expand All @@ -274,7 +274,7 @@ class CreateFile(CreateResource):

def __init__(self, parent, name):
resource = parent.project.get_file(self._get_child_path(parent, name))
super(CreateFile, self).__init__(resource)
super().__init__(resource)


class RemoveResource(Change):
Expand Down Expand Up @@ -318,7 +318,7 @@ def create_job_set(task_handle, change):
return task_handle.create_jobset(str(change), count_changes(change))


class _ResourceOperations(object):
class _ResourceOperations:
def __init__(self, project):
self.project = project
self.fscommands = project.fscommands
Expand Down Expand Up @@ -374,7 +374,7 @@ def _create_resource(self, file_name, kind="file"):
fscommands.create_file(resource_path)
else:
fscommands.create_folder(resource_path)
except IOError as e:
except OSError as e:
raise exceptions.RopeError(e)


Expand All @@ -388,7 +388,7 @@ def _get_destination_for_move(resource, destination):
return destination


class ChangeToData(object):
class ChangeToData:
def convertChangeSet(self, change):
description = change.description
changes = []
Expand Down Expand Up @@ -416,7 +416,7 @@ def __call__(self, change):
return (change_type.__name__, method(change))


class DataToChange(object):
class DataToChange:
def __init__(self, project):
self.project = project

Expand Down
14 changes: 7 additions & 7 deletions rope/base/codeanalyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tokenize


class ChangeCollector(object):
class ChangeCollector:
def __init__(self, text):
self.text = text
self.changes = []
Expand Down Expand Up @@ -32,7 +32,7 @@ def get_changed(self):
return result


class SourceLinesAdapter(object):
class SourceLinesAdapter:
"""Adapts source to Lines interface
Note: The creation of this class is expensive.
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_line_end(self, lineno):
return self.starts[lineno] - 1


class ArrayLinesAdapter(object):
class ArrayLinesAdapter:
def __init__(self, lines):
self.lines = lines

Expand All @@ -82,7 +82,7 @@ def length(self):
return len(self.lines)


class LinesToReadline(object):
class LinesToReadline:
def __init__(self, lines, start):
self.lines = lines
self.current = start
Expand All @@ -97,7 +97,7 @@ def __call__(self):
return self.readline()


class _CustomGenerator(object):
class _CustomGenerator:
def __init__(self, lines):
self.lines = lines
self.in_string = ""
Expand Down Expand Up @@ -162,7 +162,7 @@ def custom_generator(lines):
return _CustomGenerator(lines)()


class LogicalLineFinder(object):
class LogicalLineFinder:
def __init__(self, lines):
self.lines = lines

Expand Down Expand Up @@ -245,7 +245,7 @@ def tokenizer_generator(lines):
return LogicalLineFinder(lines).generate_regions()


class CachingLogicalLineFinder(object):
class CachingLogicalLineFinder:
def __init__(self, lines, generate=custom_generator):
self.lines = lines
self._generate = generate
Expand Down
4 changes: 2 additions & 2 deletions rope/base/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def eval_str2(holding_scope, name):
return eval_node2(holding_scope, node)


class ScopeNameFinder(object):
class ScopeNameFinder:
def __init__(self, pymodule):
self.module_scope = pymodule.get_scope()
self.lines = pymodule.lines
Expand Down Expand Up @@ -145,7 +145,7 @@ def _find_module(self, module_name):
)


class StatementEvaluator(object):
class StatementEvaluator:
def __init__(self, scope):
self.scope = scope
self.result = None
Expand Down
8 changes: 4 additions & 4 deletions rope/base/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __init__(self, filename, lineno, message):
self.filename = filename
self.lineno = lineno
self.message_ = message
super(ModuleSyntaxError, self).__init__(
"Syntax error in file <%s> line <%s>: %s" % (filename, lineno, message)
super().__init__(
"Syntax error in file <{}> line <{}>: {}".format(filename, lineno, message)
)


Expand All @@ -57,6 +57,6 @@ class ModuleDecodeError(RopeError):
def __init__(self, filename, message):
self.filename = filename
self.message_ = message
super(ModuleDecodeError, self).__init__(
"Cannot decode file <%s>: %s" % (filename, message)
super().__init__(
"Cannot decode file <{}>: {}".format(filename, message)
)
Loading

0 comments on commit 73d8db3

Please sign in to comment.