Skip to content

Commit 28053fb

Browse files
committed
Remove unnecessary object base class in docs (#10366).
Also add a note about inheritance from `object` being default.
1 parent d4bbab2 commit 28053fb

File tree

13 files changed

+26
-17
lines changed

13 files changed

+26
-17
lines changed

Doc/includes/mp_newtype.py

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

1313
##
1414

15-
class Foo(object):
15+
class Foo:
1616
def f(self):
1717
print('you called Foo.f()')
1818
def g(self):

Doc/includes/sqlite3/adapter_point_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sqlite3
22

3-
class Point(object):
3+
class Point:
44
def __init__(self, x, y):
55
self.x, self.y = x, y
66

Doc/includes/sqlite3/adapter_point_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sqlite3
22

3-
class Point(object):
3+
class Point:
44
def __init__(self, x, y):
55
self.x, self.y = x, y
66

Doc/includes/sqlite3/converter_point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sqlite3
22

3-
class Point(object):
3+
class Point:
44
def __init__(self, x, y):
55
self.x, self.y = x, y
66

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ already existing object, rather than the newly-created :class:`Namespace` object
13121312
that is normally used. This can be achieved by specifying the ``namespace=``
13131313
keyword argument::
13141314

1315-
>>> class C(object):
1315+
>>> class C:
13161316
... pass
13171317
...
13181318
>>> c = C()

Doc/library/ctypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ your own classes be used as function arguments. :mod:`ctypes` looks for an
369369
:attr:`_as_parameter_` attribute and uses this as the function argument. Of
370370
course, it must be one of integer, string, or bytes::
371371

372-
>>> class Bottles(object):
372+
>>> class Bottles:
373373
... def __init__(self, number):
374374
... self._as_parameter_ = number
375375
...

Doc/library/functions.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ are always available. They are listed here in alphabetical order.
259259
['Struct', '__builtins__', '__doc__', '__file__', '__name__',
260260
'__package__', '_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
261261
'unpack', 'unpack_from']
262-
>>> class Foo(object):
262+
>>> class Foo:
263263
... def __dir__(self):
264264
... return ["kan", "ga", "roo"]
265265
...
@@ -903,7 +903,7 @@ are always available. They are listed here in alphabetical order.
903903
function for setting, and *fdel* a function for del'ing, an attribute. Typical
904904
use is to define a managed attribute ``x``::
905905

906-
class C(object):
906+
class C:
907907
def __init__(self):
908908
self._x = None
909909

@@ -922,7 +922,7 @@ are always available. They are listed here in alphabetical order.
922922
property will copy *fget*'s docstring (if it exists). This makes it possible to
923923
create read-only properties easily using :func:`property` as a :term:`decorator`::
924924

925-
class Parrot(object):
925+
class Parrot:
926926
def __init__(self):
927927
self._voltage = 100000
928928

@@ -939,7 +939,7 @@ are always available. They are listed here in alphabetical order.
939939
corresponding accessor function set to the decorated function. This is
940940
best explained with an example::
941941

942-
class C(object):
942+
class C:
943943
def __init__(self):
944944
self._x = None
945945

@@ -1243,7 +1243,7 @@ are always available. They are listed here in alphabetical order.
12431243
attribute. For example, the following two statements create identical
12441244
:class:`type` objects:
12451245

1246-
>>> class X(object):
1246+
>>> class X:
12471247
... a = 1
12481248
...
12491249
>>> X = type('X', (object,), dict(a=1))

Doc/library/inspect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ for arbitrary getset descriptors invoking these may trigger
604604
code execution::
605605

606606
# example code for resolving the builtin descriptor types
607-
class _foo(object):
607+
class _foo:
608608
__slots__ = ['foo']
609609

610610
slot_descriptor = type(_foo.foo)

Doc/library/itertools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ loops that truncate the stream.
322322

323323
:func:`groupby` is equivalent to::
324324

325-
class groupby(object):
325+
class groupby:
326326
# [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
327327
# [list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
328328
def __init__(self, iterable, key=None):

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ callables with the manager class. For example::
13341334

13351335
from multiprocessing.managers import BaseManager
13361336

1337-
class MathsClass(object):
1337+
class MathsClass:
13381338
def add(self, x, y):
13391339
return x + y
13401340
def mul(self, x, y):

Doc/library/sqlite3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ Letting your object adapt itself
710710
This is a good approach if you write the class yourself. Let's suppose you have
711711
a class like this::
712712

713-
class Point(object):
713+
class Point:
714714
def __init__(self, x, y):
715715
self.x, self.y = x, y
716716

Doc/reference/compound_stmts.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,16 @@ A class definition defines a class object (see section :ref:`types`):
561561
A class definition is an executable statement. The inheritance list usually
562562
gives a list of base classes (see :ref:`metaclasses` for more advanced uses), so
563563
each item in the list should evaluate to a class object which allows
564-
subclassing.
564+
subclassing. Classes without an inheritance list inherit, by default, from the
565+
base class :class:`object`; hence, ::
566+
567+
class Foo:
568+
pass
569+
570+
is equivalent to ::
571+
572+
class Foo(object):
573+
pass
565574

566575
The class's suite is then executed in a new execution frame (see :ref:`naming`),
567576
using a newly created local namespace and the original global namespace.

Doc/reference/datamodel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ to work correctly if defined on an object's type, not in the object's instance
19871987
dictionary. That behaviour is the reason why the following code raises an
19881988
exception::
19891989

1990-
>>> class C(object):
1990+
>>> class C:
19911991
... pass
19921992
...
19931993
>>> c = C()

0 commit comments

Comments
 (0)