Skip to content

Commit 70c5f2a

Browse files
Use more PEP 570 syntax in the documentation. (GH-13720)
1 parent 2085bd0 commit 70c5f2a

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

Doc/faq/programming.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ desired effect in a number of ways.
554554
5) Or bundle up values in a class instance::
555555

556556
class callByRef:
557-
def __init__(self, **args):
558-
for (key, value) in args.items():
557+
def __init__(self, /, **args):
558+
for key, value in args.items():
559559
setattr(self, key, value)
560560

561561
def func4(args):

Doc/howto/logging-cookbook.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ information. When you call one of the logging methods on an instance of
579579
information in the delegated call. Here's a snippet from the code of
580580
:class:`LoggerAdapter`::
581581

582-
def debug(self, msg, *args, **kwargs):
582+
def debug(self, msg, /, *args, **kwargs):
583583
"""
584584
Delegate a debug call to the underlying logger, after adding
585585
contextual information from this adapter instance.
@@ -1079,7 +1079,7 @@ call ``str()`` on that object to get the actual format string. Consider the
10791079
following two classes::
10801080

10811081
class BraceMessage:
1082-
def __init__(self, fmt, *args, **kwargs):
1082+
def __init__(self, fmt, /, *args, **kwargs):
10831083
self.fmt = fmt
10841084
self.args = args
10851085
self.kwargs = kwargs
@@ -1088,7 +1088,7 @@ following two classes::
10881088
return self.fmt.format(*self.args, **self.kwargs)
10891089

10901090
class DollarMessage:
1091-
def __init__(self, fmt, **kwargs):
1091+
def __init__(self, fmt, /, **kwargs):
10921092
self.fmt = fmt
10931093
self.kwargs = kwargs
10941094

@@ -1143,7 +1143,7 @@ to the above, as in the following example::
11431143

11441144
import logging
11451145

1146-
class Message(object):
1146+
class Message:
11471147
def __init__(self, fmt, args):
11481148
self.fmt = fmt
11491149
self.args = args
@@ -1155,7 +1155,7 @@ to the above, as in the following example::
11551155
def __init__(self, logger, extra=None):
11561156
super(StyleAdapter, self).__init__(logger, extra or {})
11571157

1158-
def log(self, level, msg, *args, **kwargs):
1158+
def log(self, level, msg, /, *args, **kwargs):
11591159
if self.isEnabledFor(level):
11601160
msg, kwargs = self.process(msg, kwargs)
11611161
self.logger._log(level, Message(msg, args), (), **kwargs)
@@ -1301,7 +1301,7 @@ You can also subclass :class:`QueueListener` to get messages from other kinds
13011301
of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
13021302

13031303
class ZeroMQSocketListener(QueueListener):
1304-
def __init__(self, uri, *handlers, **kwargs):
1304+
def __init__(self, uri, /, *handlers, **kwargs):
13051305
self.ctx = kwargs.get('ctx') or zmq.Context()
13061306
socket = zmq.Socket(self.ctx, zmq.SUB)
13071307
socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything
@@ -1706,8 +1706,8 @@ which uses JSON to serialise the event in a machine-parseable manner::
17061706
import json
17071707
import logging
17081708

1709-
class StructuredMessage(object):
1710-
def __init__(self, message, **kwargs):
1709+
class StructuredMessage:
1710+
def __init__(self, message, /, **kwargs):
17111711
self.message = message
17121712
self.kwargs = kwargs
17131713

@@ -1750,8 +1750,8 @@ as in the following complete example::
17501750
return o.encode('unicode_escape').decode('ascii')
17511751
return super(Encoder, self).default(o)
17521752

1753-
class StructuredMessage(object):
1754-
def __init__(self, message, **kwargs):
1753+
class StructuredMessage:
1754+
def __init__(self, message, /, **kwargs):
17551755
self.message = message
17561756
self.kwargs = kwargs
17571757

@@ -1982,17 +1982,17 @@ object as a message format string, and that the logging package will call
19821982
:func:`str` on that object to get the actual format string. Consider the
19831983
following two classes::
19841984

1985-
class BraceMessage(object):
1986-
def __init__(self, fmt, *args, **kwargs):
1985+
class BraceMessage:
1986+
def __init__(self, fmt, /, *args, **kwargs):
19871987
self.fmt = fmt
19881988
self.args = args
19891989
self.kwargs = kwargs
19901990

19911991
def __str__(self):
19921992
return self.fmt.format(*self.args, **self.kwargs)
19931993

1994-
class DollarMessage(object):
1995-
def __init__(self, fmt, **kwargs):
1994+
class DollarMessage:
1995+
def __init__(self, fmt, /, **kwargs):
19961996
self.fmt = fmt
19971997
self.kwargs = kwargs
19981998

@@ -2457,7 +2457,7 @@ scope of the context manager::
24572457
import logging
24582458
import sys
24592459

2460-
class LoggingContext(object):
2460+
class LoggingContext:
24612461
def __init__(self, logger, level=None, handler=None, close=True):
24622462
self.logger = logger
24632463
self.level = level

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ The :mod:`functools` module defines the following functions:
252252
18
253253

254254

255-
.. class:: partialmethod(func, *args, **keywords)
255+
.. class:: partialmethod(func, /, *args, **keywords)
256256

257257
Return a new :class:`partialmethod` descriptor which behaves
258258
like :class:`partial` except that it is designed to be used as a method

Doc/reference/datamodel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ class defining the method.
18091809
class, as in::
18101810

18111811
class Philosopher:
1812-
def __init_subclass__(cls, default_name, **kwargs):
1812+
def __init_subclass__(cls, /, default_name, **kwargs):
18131813
super().__init_subclass__(**kwargs)
18141814
cls.default_name = default_name
18151815

0 commit comments

Comments
 (0)