]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use the zero argument form of super() in examples for Python3 docs. (GH-22314) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 26 Apr 2021 22:16:08 +0000 (15:16 -0700)
committerGitHub <noreply@github.com>
Mon, 26 Apr 2021 22:16:08 +0000 (15:16 -0700)
(cherry picked from commit 52cd6d5e1b2bece0d8efb58b1af41071c914ebe6)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
Doc/howto/logging-cookbook.rst
Doc/library/argparse.rst
Doc/library/contextlib.rst
Doc/library/multiprocessing.rst
Doc/library/unittest.mock-examples.rst
Doc/library/weakref.rst

index de0f834551f5ddd61d2b0990200f80bce076f942..5777a4c5031f85653234b90583f045f85c634cf8 100644 (file)
@@ -1188,7 +1188,7 @@ to the above, as in the following example::
 
     class StyleAdapter(logging.LoggerAdapter):
         def __init__(self, logger, extra=None):
-            super(StyleAdapter, self).__init__(logger, extra or {})
+            super().__init__(logger, extra or {})
 
         def log(self, level, msg, /, *args, **kwargs):
             if self.isEnabledFor(level):
@@ -1783,7 +1783,7 @@ as in the following complete example::
                 return tuple(o)
             elif isinstance(o, unicode):
                 return o.encode('unicode_escape').decode('ascii')
-            return super(Encoder, self).default(o)
+            return super().default(o)
 
     class StructuredMessage:
         def __init__(self, message, /, **kwargs):
@@ -2175,11 +2175,11 @@ class, as shown in the following example::
             """
             Format an exception so that it prints on a single line.
             """
-            result = super(OneLineExceptionFormatter, self).formatException(exc_info)
+            result = super().formatException(exc_info)
             return repr(result)  # or format into one line however you want to
 
         def format(self, record):
-            s = super(OneLineExceptionFormatter, self).format(record)
+            s = super().format(record)
             if record.exc_text:
                 s = s.replace('\n', '') + '|'
             return s
@@ -2813,7 +2813,7 @@ refer to the comments in the code snippet for more detailed information.
     #
     class QtHandler(logging.Handler):
         def __init__(self, slotfunc, *args, **kwargs):
-            super(QtHandler, self).__init__(*args, **kwargs)
+            super().__init__(*args, **kwargs)
             self.signaller = Signaller()
             self.signaller.signal.connect(slotfunc)
 
@@ -2883,7 +2883,7 @@ refer to the comments in the code snippet for more detailed information.
         }
 
         def __init__(self, app):
-            super(Window, self).__init__()
+            super().__init__()
             self.app = app
             self.textedit = te = QtWidgets.QPlainTextEdit(self)
             # Set whatever the default monospace font is for the platform
index 2ec7ea3ecb4e3c909d2252f215c451fa0c189863..63648ed81d8c1c337e0ef1e14b594f17332c2a16 100644 (file)
@@ -825,7 +825,7 @@ An example of a custom action::
    ...     def __init__(self, option_strings, dest, nargs=None, **kwargs):
    ...         if nargs is not None:
    ...             raise ValueError("nargs not allowed")
-   ...         super(FooAction, self).__init__(option_strings, dest, **kwargs)
+   ...         super().__init__(option_strings, dest, **kwargs)
    ...     def __call__(self, parser, namespace, values, option_string=None):
    ...         print('%r %r %r' % (namespace, values, option_string))
    ...         setattr(namespace, self.dest, values)
index 73b24e5f251a94a386b9ef493f3ba168dee22cfc..6b2286e8968eb0eb5c977a23291231bddecccf52 100644 (file)
@@ -638,7 +638,7 @@ even further by means of a small helper class::
 
    class Callback(ExitStack):
        def __init__(self, callback, /, *args, **kwds):
-           super(Callback, self).__init__()
+           super().__init__()
            self.callback(callback, *args, **kwds)
 
        def cancel(self):
index 041410900dff6474865b7d3e85acfd66a27575ac..5777344953a772be8cae6ef96e309f776824b62b 100644 (file)
@@ -1916,7 +1916,7 @@ client to access it remotely::
     >>> class Worker(Process):
     ...     def __init__(self, q):
     ...         self.q = q
-    ...         super(Worker, self).__init__()
+    ...         super().__init__()
     ...     def run(self):
     ...         self.q.put('local hello')
     ...
index e650bb1e23e03ee873b3e53ebec7774cfb37d15a..24a18c684846867312f9e38a49533e8a93676344 100644 (file)
@@ -893,7 +893,7 @@ Here's an example implementation:
     ...     def __call__(self, /, *args, **kwargs):
     ...         args = deepcopy(args)
     ...         kwargs = deepcopy(kwargs)
-    ...         return super(CopyingMock, self).__call__(*args, **kwargs)
+    ...         return super().__call__(*args, **kwargs)
     ...
     >>> c = CopyingMock(return_value=None)
     >>> arg = set()
index 0d9f21d2e83a4cc492de84e5de3b2789db32add6..28f437e1a3a9408979a72595885d6fba6cbfc4f8 100644 (file)
@@ -378,7 +378,7 @@ the referent is accessed::
 
    class ExtendedRef(weakref.ref):
        def __init__(self, ob, callback=None, /, **annotations):
-           super(ExtendedRef, self).__init__(ob, callback)
+           super().__init__(ob, callback)
            self.__counter = 0
            for k, v in annotations.items():
                setattr(self, k, v)
@@ -387,7 +387,7 @@ the referent is accessed::
            """Return a pair containing the referent and the number of
            times the reference has been called.
            """
-           ob = super(ExtendedRef, self).__call__()
+           ob = super().__call__()
            if ob is not None:
                self.__counter += 1
                ob = (ob, self.__counter)