Skip to content

Commit c816c1c

Browse files
Use the zero argument form of super() in examples for Python3 docs. (GH-22314) (GH-25638)
(cherry picked from commit 52cd6d5) Co-authored-by: Andre Delfino <[email protected]>
1 parent f65f3f0 commit c816c1c

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ to the above, as in the following example::
11881188

11891189
class StyleAdapter(logging.LoggerAdapter):
11901190
def __init__(self, logger, extra=None):
1191-
super(StyleAdapter, self).__init__(logger, extra or {})
1191+
super().__init__(logger, extra or {})
11921192

11931193
def log(self, level, msg, /, *args, **kwargs):
11941194
if self.isEnabledFor(level):
@@ -1783,7 +1783,7 @@ as in the following complete example::
17831783
return tuple(o)
17841784
elif isinstance(o, unicode):
17851785
return o.encode('unicode_escape').decode('ascii')
1786-
return super(Encoder, self).default(o)
1786+
return super().default(o)
17871787

17881788
class StructuredMessage:
17891789
def __init__(self, message, /, **kwargs):
@@ -2175,11 +2175,11 @@ class, as shown in the following example::
21752175
"""
21762176
Format an exception so that it prints on a single line.
21772177
"""
2178-
result = super(OneLineExceptionFormatter, self).formatException(exc_info)
2178+
result = super().formatException(exc_info)
21792179
return repr(result) # or format into one line however you want to
21802180

21812181
def format(self, record):
2182-
s = super(OneLineExceptionFormatter, self).format(record)
2182+
s = super().format(record)
21832183
if record.exc_text:
21842184
s = s.replace('\n', '') + '|'
21852185
return s
@@ -2813,7 +2813,7 @@ refer to the comments in the code snippet for more detailed information.
28132813
#
28142814
class QtHandler(logging.Handler):
28152815
def __init__(self, slotfunc, *args, **kwargs):
2816-
super(QtHandler, self).__init__(*args, **kwargs)
2816+
super().__init__(*args, **kwargs)
28172817
self.signaller = Signaller()
28182818
self.signaller.signal.connect(slotfunc)
28192819
@@ -2883,7 +2883,7 @@ refer to the comments in the code snippet for more detailed information.
28832883
}
28842884
28852885
def __init__(self, app):
2886-
super(Window, self).__init__()
2886+
super().__init__()
28872887
self.app = app
28882888
self.textedit = te = QtWidgets.QPlainTextEdit(self)
28892889
# Set whatever the default monospace font is for the platform

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ An example of a custom action::
863863
... def __init__(self, option_strings, dest, nargs=None, **kwargs):
864864
... if nargs is not None:
865865
... raise ValueError("nargs not allowed")
866-
... super(FooAction, self).__init__(option_strings, dest, **kwargs)
866+
... super().__init__(option_strings, dest, **kwargs)
867867
... def __call__(self, parser, namespace, values, option_string=None):
868868
... print('%r %r %r' % (namespace, values, option_string))
869869
... setattr(namespace, self.dest, values)

Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ even further by means of a small helper class::
638638

639639
class Callback(ExitStack):
640640
def __init__(self, callback, /, *args, **kwds):
641-
super(Callback, self).__init__()
641+
super().__init__()
642642
self.callback(callback, *args, **kwds)
643643

644644
def cancel(self):

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ client to access it remotely::
19261926
>>> class Worker(Process):
19271927
... def __init__(self, q):
19281928
... self.q = q
1929-
... super(Worker, self).__init__()
1929+
... super().__init__()
19301930
... def run(self):
19311931
... self.q.put('local hello')
19321932
...

Doc/library/unittest.mock-examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ Here's an example implementation:
893893
... def __call__(self, /, *args, **kwargs):
894894
... args = deepcopy(args)
895895
... kwargs = deepcopy(kwargs)
896-
... return super(CopyingMock, self).__call__(*args, **kwargs)
896+
... return super().__call__(*args, **kwargs)
897897
...
898898
>>> c = CopyingMock(return_value=None)
899899
>>> arg = set()

Doc/library/weakref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ the referent is accessed::
382382

383383
class ExtendedRef(weakref.ref):
384384
def __init__(self, ob, callback=None, /, **annotations):
385-
super(ExtendedRef, self).__init__(ob, callback)
385+
super().__init__(ob, callback)
386386
self.__counter = 0
387387
for k, v in annotations.items():
388388
setattr(self, k, v)
@@ -391,7 +391,7 @@ the referent is accessed::
391391
"""Return a pair containing the referent and the number of
392392
times the reference has been called.
393393
"""
394-
ob = super(ExtendedRef, self).__call__()
394+
ob = super().__call__()
395395
if ob is not None:
396396
self.__counter += 1
397397
ob = (ob, self.__counter)

0 commit comments

Comments
 (0)