[Python-checkins] Use more PEP 570 syntax in the documentation. (GH-13720)

Serhiy Storchaka webhook-mailer at python.org
Sat Jun 1 04:38:29 EDT 2019


https://github.com/python/cpython/commit/70c5f2ae6e6a07d44a8d3f3202ea01bf697e05db
commit: 70c5f2ae6e6a07d44a8d3f3202ea01bf697e05db
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-06-01T11:38:24+03:00
summary:

Use more PEP 570 syntax in the documentation. (GH-13720)

files:
M Doc/faq/programming.rst
M Doc/howto/logging-cookbook.rst
M Doc/library/functools.rst
M Doc/reference/datamodel.rst

diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 9660a701427f..a00c6a053ef1 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -554,8 +554,8 @@ desired effect in a number of ways.
 5) Or bundle up values in a class instance::
 
       class callByRef:
-          def __init__(self, **args):
-              for (key, value) in args.items():
+          def __init__(self, /, **args):
+              for key, value in args.items():
                   setattr(self, key, value)
 
       def func4(args):
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
index 4956aa0dd957..71f9fc920fdf 100644
--- a/Doc/howto/logging-cookbook.rst
+++ b/Doc/howto/logging-cookbook.rst
@@ -579,7 +579,7 @@ information. When you call one of the logging methods on an instance of
 information in the delegated call. Here's a snippet from the code of
 :class:`LoggerAdapter`::
 
-    def debug(self, msg, *args, **kwargs):
+    def debug(self, msg, /, *args, **kwargs):
         """
         Delegate a debug call to the underlying logger, after adding
         contextual information from this adapter instance.
@@ -1079,7 +1079,7 @@ call ``str()`` on that object to get the actual format string. Consider the
 following two classes::
 
     class BraceMessage:
-        def __init__(self, fmt, *args, **kwargs):
+        def __init__(self, fmt, /, *args, **kwargs):
             self.fmt = fmt
             self.args = args
             self.kwargs = kwargs
@@ -1088,7 +1088,7 @@ following two classes::
             return self.fmt.format(*self.args, **self.kwargs)
 
     class DollarMessage:
-        def __init__(self, fmt, **kwargs):
+        def __init__(self, fmt, /, **kwargs):
             self.fmt = fmt
             self.kwargs = kwargs
 
@@ -1143,7 +1143,7 @@ to the above, as in the following example::
 
     import logging
 
-    class Message(object):
+    class Message:
         def __init__(self, fmt, args):
             self.fmt = fmt
             self.args = args
@@ -1155,7 +1155,7 @@ to the above, as in the following example::
         def __init__(self, logger, extra=None):
             super(StyleAdapter, self).__init__(logger, extra or {})
 
-        def log(self, level, msg, *args, **kwargs):
+        def log(self, level, msg, /, *args, **kwargs):
             if self.isEnabledFor(level):
                 msg, kwargs = self.process(msg, kwargs)
                 self.logger._log(level, Message(msg, args), (), **kwargs)
@@ -1301,7 +1301,7 @@ You can also subclass :class:`QueueListener` to get messages from other kinds
 of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
 
     class ZeroMQSocketListener(QueueListener):
-        def __init__(self, uri, *handlers, **kwargs):
+        def __init__(self, uri, /, *handlers, **kwargs):
             self.ctx = kwargs.get('ctx') or zmq.Context()
             socket = zmq.Socket(self.ctx, zmq.SUB)
             socket.setsockopt_string(zmq.SUBSCRIBE, '')  # subscribe to everything
@@ -1706,8 +1706,8 @@ which uses JSON to serialise the event in a machine-parseable manner::
     import json
     import logging
 
-    class StructuredMessage(object):
-        def __init__(self, message, **kwargs):
+    class StructuredMessage:
+        def __init__(self, message, /, **kwargs):
             self.message = message
             self.kwargs = kwargs
 
@@ -1750,8 +1750,8 @@ as in the following complete example::
                 return o.encode('unicode_escape').decode('ascii')
             return super(Encoder, self).default(o)
 
-    class StructuredMessage(object):
-        def __init__(self, message, **kwargs):
+    class StructuredMessage:
+        def __init__(self, message, /, **kwargs):
             self.message = message
             self.kwargs = kwargs
 
@@ -1982,8 +1982,8 @@ object as a message format string, and that the logging package will call
 :func:`str` on that object to get the actual format string. Consider the
 following two classes::
 
-    class BraceMessage(object):
-        def __init__(self, fmt, *args, **kwargs):
+    class BraceMessage:
+        def __init__(self, fmt, /, *args, **kwargs):
             self.fmt = fmt
             self.args = args
             self.kwargs = kwargs
@@ -1991,8 +1991,8 @@ following two classes::
         def __str__(self):
             return self.fmt.format(*self.args, **self.kwargs)
 
-    class DollarMessage(object):
-        def __init__(self, fmt, **kwargs):
+    class DollarMessage:
+        def __init__(self, fmt, /, **kwargs):
             self.fmt = fmt
             self.kwargs = kwargs
 
@@ -2457,7 +2457,7 @@ scope of the context manager::
     import logging
     import sys
 
-    class LoggingContext(object):
+    class LoggingContext:
         def __init__(self, logger, level=None, handler=None, close=True):
             self.logger = logger
             self.level = level
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 654a3efa214b..3a0b554e923c 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -252,7 +252,7 @@ The :mod:`functools` module defines the following functions:
       18
 
 
-.. class:: partialmethod(func, *args, **keywords)
+.. class:: partialmethod(func, /, *args, **keywords)
 
    Return a new :class:`partialmethod` descriptor which behaves
    like :class:`partial` except that it is designed to be used as a method
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 8b4d889535fb..c566dfdf856d 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1809,7 +1809,7 @@ class defining the method.
    class, as in::
 
        class Philosopher:
-           def __init_subclass__(cls, default_name, **kwargs):
+           def __init_subclass__(cls, /, default_name, **kwargs):
                super().__init_subclass__(**kwargs)
                cls.default_name = default_name
 



More information about the Python-checkins mailing list