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

This commit is contained in:
Serhiy Storchaka 2019-06-01 11:38:24 +03:00 committed by GitHub
parent 2085bd0877
commit 70c5f2ae6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 19 deletions

View File

@ -554,8 +554,8 @@ desired effect in a number of ways.
5) Or bundle up values in a class instance:: 5) Or bundle up values in a class instance::
class callByRef: class callByRef:
def __init__(self, **args): def __init__(self, /, **args):
for (key, value) in args.items(): for key, value in args.items():
setattr(self, key, value) setattr(self, key, value)
def func4(args): def func4(args):

View File

@ -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 information in the delegated call. Here's a snippet from the code of
:class:`LoggerAdapter`:: :class:`LoggerAdapter`::
def debug(self, msg, *args, **kwargs): def debug(self, msg, /, *args, **kwargs):
""" """
Delegate a debug call to the underlying logger, after adding Delegate a debug call to the underlying logger, after adding
contextual information from this adapter instance. 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:: following two classes::
class BraceMessage: class BraceMessage:
def __init__(self, fmt, *args, **kwargs): def __init__(self, fmt, /, *args, **kwargs):
self.fmt = fmt self.fmt = fmt
self.args = args self.args = args
self.kwargs = kwargs self.kwargs = kwargs
@ -1088,7 +1088,7 @@ following two classes::
return self.fmt.format(*self.args, **self.kwargs) return self.fmt.format(*self.args, **self.kwargs)
class DollarMessage: class DollarMessage:
def __init__(self, fmt, **kwargs): def __init__(self, fmt, /, **kwargs):
self.fmt = fmt self.fmt = fmt
self.kwargs = kwargs self.kwargs = kwargs
@ -1143,7 +1143,7 @@ to the above, as in the following example::
import logging import logging
class Message(object): class Message:
def __init__(self, fmt, args): def __init__(self, fmt, args):
self.fmt = fmt self.fmt = fmt
self.args = args self.args = args
@ -1155,7 +1155,7 @@ to the above, as in the following example::
def __init__(self, logger, extra=None): def __init__(self, logger, extra=None):
super(StyleAdapter, self).__init__(logger, extra or {}) 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): if self.isEnabledFor(level):
msg, kwargs = self.process(msg, kwargs) msg, kwargs = self.process(msg, kwargs)
self.logger._log(level, Message(msg, args), (), **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:: of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
class ZeroMQSocketListener(QueueListener): class ZeroMQSocketListener(QueueListener):
def __init__(self, uri, *handlers, **kwargs): def __init__(self, uri, /, *handlers, **kwargs):
self.ctx = kwargs.get('ctx') or zmq.Context() self.ctx = kwargs.get('ctx') or zmq.Context()
socket = zmq.Socket(self.ctx, zmq.SUB) socket = zmq.Socket(self.ctx, zmq.SUB)
socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything 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 json
import logging import logging
class StructuredMessage(object): class StructuredMessage:
def __init__(self, message, **kwargs): def __init__(self, message, /, **kwargs):
self.message = message self.message = message
self.kwargs = kwargs self.kwargs = kwargs
@ -1750,8 +1750,8 @@ as in the following complete example::
return o.encode('unicode_escape').decode('ascii') return o.encode('unicode_escape').decode('ascii')
return super(Encoder, self).default(o) return super(Encoder, self).default(o)
class StructuredMessage(object): class StructuredMessage:
def __init__(self, message, **kwargs): def __init__(self, message, /, **kwargs):
self.message = message self.message = message
self.kwargs = kwargs 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 :func:`str` on that object to get the actual format string. Consider the
following two classes:: following two classes::
class BraceMessage(object): class BraceMessage:
def __init__(self, fmt, *args, **kwargs): def __init__(self, fmt, /, *args, **kwargs):
self.fmt = fmt self.fmt = fmt
self.args = args self.args = args
self.kwargs = kwargs self.kwargs = kwargs
@ -1991,8 +1991,8 @@ following two classes::
def __str__(self): def __str__(self):
return self.fmt.format(*self.args, **self.kwargs) return self.fmt.format(*self.args, **self.kwargs)
class DollarMessage(object): class DollarMessage:
def __init__(self, fmt, **kwargs): def __init__(self, fmt, /, **kwargs):
self.fmt = fmt self.fmt = fmt
self.kwargs = kwargs self.kwargs = kwargs
@ -2457,7 +2457,7 @@ scope of the context manager::
import logging import logging
import sys import sys
class LoggingContext(object): class LoggingContext:
def __init__(self, logger, level=None, handler=None, close=True): def __init__(self, logger, level=None, handler=None, close=True):
self.logger = logger self.logger = logger
self.level = level self.level = level

View File

@ -252,7 +252,7 @@ The :mod:`functools` module defines the following functions:
18 18
.. class:: partialmethod(func, *args, **keywords) .. class:: partialmethod(func, /, *args, **keywords)
Return a new :class:`partialmethod` descriptor which behaves Return a new :class:`partialmethod` descriptor which behaves
like :class:`partial` except that it is designed to be used as a method like :class:`partial` except that it is designed to be used as a method

View File

@ -1809,7 +1809,7 @@ class defining the method.
class, as in:: class, as in::
class Philosopher: class Philosopher:
def __init_subclass__(cls, default_name, **kwargs): def __init_subclass__(cls, /, default_name, **kwargs):
super().__init_subclass__(**kwargs) super().__init_subclass__(**kwargs)
cls.default_name = default_name cls.default_name = default_name