Skip to content

Commit 382a345

Browse files
committed
Remove unnecessary use of 'object' in class construction
Considering we are not compatible with Python 2 anymore, we can drop the 'object' explicit inheritance in the class declaration. Pick-to: 6.8 Change-Id: Iac3a95aa9721c3ff1a755f457c0936ca157a8470 Reviewed-by: Shyamnath Premnadh <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
1 parent 03a3e61 commit 382a345

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+59
-57
lines changed

build_scripts/build_info_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_py_library(build_type, py_version, py_prefix, py_libdir, py_include_dir)
130130
return py_library
131131

132132

133-
class BuildInfoCollectorMixin(object):
133+
class BuildInfoCollectorMixin:
134134
build_base: str
135135
build_lib: str
136136
cmake: str

build_scripts/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import tomli as tomllib
1818

1919

20-
class Config(object, metaclass=Singleton):
20+
class Config(metaclass=Singleton):
2121
def __init__(self):
2222
# Constants
2323
self._build_type_all = "all"

build_scripts/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _warn_deprecated_option(option, replacement=None):
4141
log.warning(w)
4242

4343

44-
class Options(object, metaclass=Singleton):
44+
class Options(metaclass=Singleton):
4545
def __init__(self):
4646

4747
# Dictionary containing values of all the possible options.
@@ -181,7 +181,7 @@ def resolve(self):
181181
}
182182

183183

184-
class CommandMixin(object):
184+
class CommandMixin:
185185
"""Mixin for the setuptools build/install commands handling the options."""
186186

187187
_static_class_finalized_once = False

build_scripts/qtinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
platform_cmake_options)
1111

1212

13-
class QtInfo(object):
13+
class QtInfo:
1414
_instance = None # singleton helpers
1515

1616
def __new__(cls): # __new__ always a classmethod

build_scripts/setup_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from build_scripts.log import log, LogLevel
2020

2121

22-
class SetupRunner(object):
22+
class SetupRunner:
2323
def __init__(self, orig_argv):
2424
self.invocations_list = []
2525

examples/widgets/itemviews/stardelegate/starrating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
PAINTING_SCALE_FACTOR = 20
1313

1414

15-
class StarRating(object):
15+
class StarRating:
1616
""" Handle the actual painting of the stars themselves. """
1717

1818
def __init__(self, starCount=1, maxStarCount=5):

examples/widgets/tutorials/addressbook/part2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class SortedDict(dict):
16-
class Iterator(object):
16+
class Iterator:
1717
def __init__(self, sorted_dict):
1818
self._dict = sorted_dict
1919
self._keys = sorted(self._dict.keys())

examples/widgets/tutorials/addressbook/part3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class SortedDict(dict):
16-
class Iterator(object):
16+
class Iterator:
1717
def __init__(self, sorted_dict):
1818
self._dict = sorted_dict
1919
self._keys = sorted(self._dict.keys())

examples/widgets/tutorials/addressbook/part4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class SortedDict(dict):
16-
class Iterator(object):
16+
class Iterator:
1717
def __init__(self, sorted_dict):
1818
self._dict = sorted_dict
1919
self._keys = sorted(self._dict.keys())

examples/widgets/tutorials/addressbook/part5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class SortedDict(dict):
16-
class Iterator(object):
16+
class Iterator:
1717
def __init__(self, sorted_dict):
1818
self._dict = sorted_dict
1919
self._keys = sorted(self._dict.keys())

examples/widgets/tutorials/addressbook/part6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class SortedDict(dict):
17-
class Iterator(object):
17+
class Iterator:
1818
def __init__(self, sorted_dict):
1919
self._dict = sorted_dict
2020
self._keys = sorted(self._dict.keys())

examples/widgets/tutorials/addressbook/part7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class SortedDict(dict):
17-
class Iterator(object):
17+
class Iterator:
1818
def __init__(self, sorted_dict):
1919
self._dict = sorted_dict
2020
self._keys = sorted(self._dict.keys())

examples/widgets/widgets/tetrix/tetrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def draw_square(self, painter, x, y, shape):
368368
y + self.square_height() - 1, x + self.square_width() - 1, y + 1)
369369

370370

371-
class TetrixPiece(object):
371+
class TetrixPiece:
372372
coords_table = (
373373
((0, 0), (0, 0), (0, 0), (0, 0)),
374374
((0, -1), (0, 0), (-1, 0), (-1, 1)),

sources/pyside6/doc/inheritance_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def format_dict(d):
3232
return result
3333

3434

35-
class InheritanceGraph(object):
35+
class InheritanceGraph:
3636
"""
3737
Given a list of classes, determines the set of classes that they inherit
3838
from all the way to the root "object", and then is able to generate a

sources/pyside6/tests/QtCore/bug_835.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
set_counter = 0
1919

2020

21-
class Descriptor(object):
21+
class Descriptor:
2222
def __get__(self, obj, owner):
2323
global get_counter
2424

sources/pyside6/tests/QtCore/classinfo_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_function():
9393
pass
9494
self.assertRaises(TypeError, make_info(), test_function)
9595

96-
class NotAQObject(object):
96+
class NotAQObject:
9797
pass
9898
self.assertRaises(TypeError, make_info(), NotAQObject)
9999

sources/pyside6/tests/QtCore/mockclass_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from PySide6.QtCore import QCoreApplication
1919

2020

21-
class Mock(object):
21+
class Mock:
2222
def __init__(self):
2323
self.called = False
2424
self.return_value = None

sources/pyside6/tests/QtCore/qbytearray_operator_iadd_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from helper.docmodifier import DocModifier
1616

1717

18-
class BaseQByteArrayOperatorIAdd(object):
18+
class BaseQByteArrayOperatorIAdd:
1919
'''Base class for QByteArray += operator tests.
2020
2121
Implementing classes should inherit from unittest.TestCase and implement

sources/pyside6/tests/QtCore/qobject_inherits_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def testPythonMultiInheritance(self):
4444
# QObject.inherits(classname) should fail if classname isn't a
4545
# QObject subclass
4646

47-
class Parent(object):
47+
class Parent:
4848
# Dummy parent
4949
pass
5050

@@ -71,6 +71,8 @@ def __init__(self):
7171

7272
def testMultipleInheritance(self):
7373
def declareClass():
74+
# Note: 'object' cannot removed from this class declaration
75+
# in order to make it work with QObject.
7476
class Foo(object, QObject):
7577
pass
7678

sources/pyside6/tests/QtQml/bug_825_old.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MetaA(type):
3030
pass
3131

3232

33-
class A(object):
33+
class A:
3434
__metaclass__ = MetaA
3535

3636

sources/pyside6/tests/QtUiTools/bug_426.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from PySide6.QtUiTools import QUiLoader
1717

1818

19-
class Window(object):
19+
class Window:
2020
def __init__(self):
2121
loader = QUiLoader()
2222
filePath = os.path.join(os.path.dirname(__file__), 'bug_426.ui')

sources/pyside6/tests/QtWidgets/bug_836.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
from PySide6.QtWidgets import QApplication, QFrame
1616

1717

18-
class Mixin1(object):
18+
class Mixin1:
1919
pass
2020

2121

22-
class Mixin2(object):
22+
class Mixin2:
2323
pass
2424

2525

26-
class Mixin3(object):
26+
class Mixin3:
2727
pass
2828

2929

sources/pyside6/tests/QtWidgets/bug_921.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Signaller(QObject):
2424
s3 = Signal()
2525

2626

27-
class Window(object):
27+
class Window:
2828

2929
def __init__(self, s):
3030
self._window = QMainWindow()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
class PysideImportTest2(object):
1+
class PysideImportTest2:
22
pass

sources/pyside6/tests/QtWidgets/qvariant_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def itemChange(self, change, value):
2828
return value
2929

3030

31-
class Sequence(object):
31+
class Sequence:
3232
# Having the __getitem__ method on a class transform the Python
3333
# type to a PySequence.
3434
# Before the patch: aa75437f9119d997dd290471ac3e2cc88ca88bf1

sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from PySide6.QtCore import QObject, Signal, Slot
2121

2222

23-
class Mixin(object):
23+
class Mixin:
2424
mixinSignal = Signal()
2525

2626
def __init__(self, *args, **kwargs):
@@ -39,7 +39,7 @@ def mixinTwoSlot(self):
3939
self.mixinTwoSlotCalled = True
4040

4141

42-
class MixinThree(object):
42+
class MixinThree:
4343
mixinThreeSignal = Signal()
4444

4545
def __init__(self, *args, **kwargs):

sources/pyside6/tests/pysidetest/multiple_inheritance_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def xprint(*args, **kw):
2222

2323

2424
# This is the original testcase of PYSIDE-1564
25-
class Age(object):
25+
class Age:
2626
def __init__(self, age=0, **kwds):
2727
super().__init__(**kwds)
2828

@@ -117,7 +117,7 @@ class II(G, H, QtWidgets.QLabel):
117117

118118
# PYSIDE-2294: Friedemann's test adapted.
119119
# We need to ignore positional args in mixin classes.
120-
class Ui_X_MainWindow(object): # Emulating uic
120+
class Ui_X_MainWindow: # Emulating uic
121121
def setupUi(self, MainWindow):
122122
MainWindow.resize(400, 300)
123123
self.lbl = QLabel(self)
@@ -160,7 +160,7 @@ def testParentDoesNotCrash(self):
160160

161161
# PYSIDE-2654: Additional missing init test.
162162
# This must work if no __init__ is defined (Ui_Form)
163-
class Ui_Form(object):
163+
class Ui_Form:
164164
pass
165165

166166

sources/pyside6/tests/pysidetest/property_python_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def spam(self):
8989
raise PropertyDel(self._spam)
9090

9191

92-
class PropertyDocBase(object):
92+
class PropertyDocBase:
9393
_spam = 1
9494

9595
def _get_spam(self):
@@ -188,7 +188,7 @@ def test_property_builtin_doc_writable(self):
188188
@unittest.skipIf(sys.flags.optimize >= 2,
189189
"Docstrings are omitted with -O2 and above")
190190
def test_property_decorator_doc_writable(self):
191-
class PropertyWritableDoc(object):
191+
class PropertyWritableDoc:
192192

193193
@Property(object)
194194
def spam(self):

sources/pyside6/tests/registry/init_platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def set_ospaths(build_dir):
104104
sourcepath = os.path.splitext(__file__)[0] + ".py"
105105

106106

107-
class Formatter(object):
107+
class Formatter:
108108
"""
109109
Formatter is formatting the signature listing of an enumerator.
110110

sources/pyside6/tests/util/helper/basicpyslotcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import gc
66

77

8-
class BasicPySlotCase(object):
8+
class BasicPySlotCase:
99
'''Base class that tests python slots and signal emissions.
1010
1111
Python slots are defined as any callable passed to QObject.connect().

sources/pyside6/tests/util/helper/docmodifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(mcs, name, bases, dct):
5959
if __name__ == '__main__':
6060

6161
# tests
62-
class BaseTest(object):
62+
class BaseTest:
6363
__metaclass__ = DocModifier
6464

6565
def testBase(self):

sources/pyside6/tests/util/processtimer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __str__(self):
1515
return repr(self.msg)
1616

1717

18-
class ProcessTimer(object):
18+
class ProcessTimer:
1919
'''Timeout function for controlling a subprocess.Popen instance.
2020
2121
Naive implementation using busy loop, see later other means

sources/shiboken6/libshiboken/embed/signature_bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def prepare_zipfile():
167167
return sys.meta_path, EmbeddableZipImporter(vzip)
168168

169169

170-
class EmbeddableZipImporter(object):
170+
class EmbeddableZipImporter:
171171

172172
def __init__(self, zip_file):
173173
def p2m(filename):

sources/shiboken6/shibokenmodule/Shiboken.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Shiboken, except for defaults which are replaced by "...".
1313
from shiboken6 import Shiboken
1414

1515

16-
class Object(object):
16+
class Object:
1717

1818
def __init__(self) -> None: ...
1919

2020

21-
class VoidPtr(object):
21+
class VoidPtr:
2222
def __init__(self, value: int) -> None: ...
2323

2424

sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def signal_check(thing):
4444
return thing and type(thing) in (Signal, SignalInstance)
4545

4646

47-
class ExactEnumerator(object):
47+
class ExactEnumerator:
4848
"""
4949
ExactEnumerator enumerates all signatures in a module as they are.
5050

sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
indent = " " * 4
3131

3232

33-
class Writer(object):
33+
class Writer:
3434
def __init__(self, outfile, *args):
3535
self.outfile = outfile
3636
self.history = [True, True]

0 commit comments

Comments
 (0)