Skip to content

Commit 530c3bb

Browse files
[3.12] Format None, True, False and NotImplemented as literals (GH-118758) (GH-118794)
(cherry picked from commit 05c2fe1)
1 parent b83b3cb commit 530c3bb

33 files changed

+76
-75
lines changed

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Object Protocol
1616
1717
Properly handle returning :c:data:`Py_NotImplemented` from within a C
1818
function (that is, create a new :term:`strong reference`
19-
to NotImplemented and return it).
19+
to :const:`NotImplemented` and return it).
2020

2121

2222
.. c:macro:: Py_PRINT_RAW

Doc/library/_thread.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ Lock objects have the following methods:
166166
time can acquire a lock --- that's their reason for existence).
167167

168168
If the *blocking* argument is present, the action depends on its
169-
value: if it is False, the lock is only acquired if it can be acquired
170-
immediately without waiting, while if it is True, the lock is acquired
169+
value: if it is false, the lock is only acquired if it can be acquired
170+
immediately without waiting, while if it is true, the lock is acquired
171171
unconditionally as above.
172172

173173
If the floating-point *timeout* argument is present and positive, it
174174
specifies the maximum wait time in seconds before returning. A negative
175175
*timeout* argument specifies an unbounded wait. You cannot specify
176-
a *timeout* if *blocking* is False.
176+
a *timeout* if *blocking* is false.
177177

178178
The return value is ``True`` if the lock is acquired successfully,
179179
``False`` if not.

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ Running Tasks Concurrently
507507
# [2, 6, 24]
508508

509509
.. note::
510-
If *return_exceptions* is False, cancelling gather() after it
510+
If *return_exceptions* is false, cancelling gather() after it
511511
has been marked done won't cancel any submitted awaitables.
512512
For instance, gather can be marked done after propagating an
513513
exception to the caller, therefore, calling ``gather.cancel()``

Doc/library/bdb.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The :mod:`bdb` module also defines two classes:
8686

8787
.. attribute:: temporary
8888

89-
True if a :class:`Breakpoint` at (file, line) is temporary.
89+
``True`` if a :class:`Breakpoint` at (file, line) is temporary.
9090

9191
.. attribute:: cond
9292

@@ -99,7 +99,7 @@ The :mod:`bdb` module also defines two classes:
9999

100100
.. attribute:: enabled
101101

102-
True if :class:`Breakpoint` is enabled.
102+
``True`` if :class:`Breakpoint` is enabled.
103103

104104
.. attribute:: bpbynumber
105105

@@ -215,22 +215,22 @@ The :mod:`bdb` module also defines two classes:
215215

216216
.. method:: is_skipped_line(module_name)
217217

218-
Return True if *module_name* matches any skip pattern.
218+
Return ``True`` if *module_name* matches any skip pattern.
219219

220220
.. method:: stop_here(frame)
221221

222-
Return True if *frame* is below the starting frame in the stack.
222+
Return ``True`` if *frame* is below the starting frame in the stack.
223223

224224
.. method:: break_here(frame)
225225

226-
Return True if there is an effective breakpoint for this line.
226+
Return ``True`` if there is an effective breakpoint for this line.
227227

228228
Check whether a line or function breakpoint exists and is in effect. Delete temporary
229229
breakpoints based on information from :func:`effective`.
230230

231231
.. method:: break_anywhere(frame)
232232

233-
Return True if any breakpoint exists for *frame*'s filename.
233+
Return ``True`` if any breakpoint exists for *frame*'s filename.
234234

235235
Derived classes should override these methods to gain control over debugger
236236
operation.
@@ -344,7 +344,7 @@ The :mod:`bdb` module also defines two classes:
344344

345345
.. method:: get_break(filename, lineno)
346346

347-
Return True if there is a breakpoint for *lineno* in *filename*.
347+
Return ``True`` if there is a breakpoint for *lineno* in *filename*.
348348

349349
.. method:: get_breaks(filename, lineno)
350350

@@ -408,7 +408,7 @@ Finally, the module defines the following functions:
408408

409409
.. function:: checkfuncname(b, frame)
410410

411-
Return True if we should break here, depending on the way the
411+
Return ``True`` if we should break here, depending on the way the
412412
:class:`Breakpoint` *b* was set.
413413

414414
If it was set via line number, it checks if
@@ -427,14 +427,14 @@ Finally, the module defines the following functions:
427427
:attr:`bplist <bdb.Breakpoint.bplist>` for the
428428
(:attr:`file <bdb.Breakpoint.file>`, :attr:`line <bdb.Breakpoint.line>`)
429429
(which must exist) that is :attr:`enabled <bdb.Breakpoint.enabled>`, for
430-
which :func:`checkfuncname` is True, and that has neither a False
430+
which :func:`checkfuncname` is true, and that has neither a false
431431
:attr:`condition <bdb.Breakpoint.cond>` nor positive
432432
:attr:`ignore <bdb.Breakpoint.ignore>` count. The *flag*, meaning that a
433-
temporary breakpoint should be deleted, is False only when the
433+
temporary breakpoint should be deleted, is ``False`` only when the
434434
:attr:`cond <bdb.Breakpoint.cond>` cannot be evaluated (in which case,
435435
:attr:`ignore <bdb.Breakpoint.ignore>` count is ignored).
436436

437-
If no such entry exists, then (None, None) is returned.
437+
If no such entry exists, then ``(None, None)`` is returned.
438438

439439

440440
.. function:: set_trace()

Doc/library/compileall.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Public functions
226226
The *invalidation_mode* parameter was added.
227227

228228
.. versionchanged:: 3.7.2
229-
The *invalidation_mode* parameter's default value is updated to None.
229+
The *invalidation_mode* parameter's default value is updated to ``None``.
230230

231231
.. versionchanged:: 3.8
232232
Setting *workers* to 0 now chooses the optimal number of cores.
@@ -289,7 +289,7 @@ Public functions
289289
The *invalidation_mode* parameter was added.
290290

291291
.. versionchanged:: 3.7.2
292-
The *invalidation_mode* parameter's default value is updated to None.
292+
The *invalidation_mode* parameter's default value is updated to ``None``.
293293

294294
.. versionchanged:: 3.9
295295
Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* arguments.
@@ -318,7 +318,7 @@ Public functions
318318
The *invalidation_mode* parameter was added.
319319

320320
.. versionchanged:: 3.7.2
321-
The *invalidation_mode* parameter's default value is updated to None.
321+
The *invalidation_mode* parameter's default value is updated to ``None``.
322322

323323
To force a recompile of all the :file:`.py` files in the :file:`Lib/`
324324
subdirectory and all its subdirectories::

Doc/library/csv.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ The :mod:`csv` module defines the following constants:
349349
``None``. This is similar to :data:`QUOTE_ALL`, except that if a
350350
field value is ``None`` an empty (unquoted) string is written.
351351

352-
Instructs :class:`reader` objects to interpret an empty (unquoted) field as None and
353-
to otherwise behave as :data:`QUOTE_ALL`.
352+
Instructs :class:`reader` objects to interpret an empty (unquoted) field
353+
as ``None`` and to otherwise behave as :data:`QUOTE_ALL`.
354354

355355
.. versionadded:: 3.12
356356

Doc/library/dataclasses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Module contents
278278
generated equality and comparison methods (:meth:`~object.__eq__`,
279279
:meth:`~object.__gt__`, et al.).
280280

281-
- *metadata*: This can be a mapping or None. None is treated as
281+
- *metadata*: This can be a mapping or ``None``. ``None`` is treated as
282282
an empty dict. This value is wrapped in
283283
:func:`~types.MappingProxyType` to make it read-only, and exposed
284284
on the :class:`Field` object. It is not used at all by Data

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ The :mod:`functools` module defines the following functions:
325325
.. versionadded:: 3.2
326326

327327
.. versionchanged:: 3.4
328-
Returning NotImplemented from the underlying comparison function for
328+
Returning ``NotImplemented`` from the underlying comparison function for
329329
unrecognised types is now supported.
330330

331331
.. function:: partial(func, /, *args, **keywords)

Doc/library/gc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The :mod:`gc` module provides the following functions:
6969
.. function:: get_objects(generation=None)
7070

7171
Returns a list of all objects tracked by the collector, excluding the list
72-
returned. If *generation* is not None, return only the objects tracked by
72+
returned. If *generation* is not ``None``, return only the objects tracked by
7373
the collector that are in that generation.
7474

7575
.. versionchanged:: 3.8

Doc/library/imaplib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ base class:
3939
initialized. If *host* is not specified, ``''`` (the local host) is used. If
4040
*port* is omitted, the standard IMAP4 port (143) is used. The optional *timeout*
4141
parameter specifies a timeout in seconds for the connection attempt.
42-
If timeout is not given or is None, the global default socket timeout is used.
42+
If timeout is not given or is ``None``, the global default socket timeout is used.
4343

4444
The :class:`IMAP4` class supports the :keyword:`with` statement. When used
4545
like this, the IMAP4 ``LOGOUT`` command is issued automatically when the
@@ -97,7 +97,7 @@ There's also a subclass for secure connections:
9797
best practices.
9898

9999
The optional *timeout* parameter specifies a timeout in seconds for the
100-
connection attempt. If timeout is not given or is None, the global default
100+
connection attempt. If timeout is not given or is ``None``, the global default
101101
socket timeout is used.
102102

103103
.. versionchanged:: 3.3
@@ -360,7 +360,7 @@ An :class:`IMAP4` instance has the following methods:
360360

361361
Opens socket to *port* at *host*. The optional *timeout* parameter
362362
specifies a timeout in seconds for the connection attempt.
363-
If timeout is not given or is None, the global default socket timeout
363+
If timeout is not given or is ``None``, the global default socket timeout
364364
is used. Also note that if the *timeout* parameter is set to be zero,
365365
it will raise a :class:`ValueError` to reject creating a non-blocking socket.
366366
This method is implicitly called by the :class:`IMAP4` constructor.

Doc/library/importlib.resources.abc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@
103103

104104
.. abstractmethod:: is_dir()
105105

106-
Return True if self is a directory.
106+
Return ``True`` if self is a directory.
107107

108108
.. abstractmethod:: is_file()
109109

110-
Return True if self is a file.
110+
Return ``True`` if self is a file.
111111

112112
.. abstractmethod:: joinpath(*pathsegments)
113113

Doc/library/logging.handlers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ and :meth:`flush` methods).
6666

6767
:param stream: The stream that the handler should use.
6868

69-
:return: the old stream, if the stream was changed, or *None* if it wasn't.
69+
:return: the old stream, if the stream was changed, or ``None`` if it wasn't.
7070

7171
.. versionadded:: 3.7
7272

Doc/library/math.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Number-theoretic and representation functions
252252
Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates
253253
to zero when ``k > n``.
254254

255-
If *k* is not specified or is None, then *k* defaults to *n*
255+
If *k* is not specified or is ``None``, then *k* defaults to *n*
256256
and the function returns ``n!``.
257257

258258
Raises :exc:`TypeError` if either of the arguments are not integers.

Doc/library/multiprocessing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,9 +2472,9 @@ multiple connections at the same time.
24722472
generally be omitted since it can usually be inferred from the format of
24732473
*address*. (See :ref:`multiprocessing-address-formats`)
24742474

2475-
If *authkey* is given and not None, it should be a byte string and will be
2475+
If *authkey* is given and not ``None``, it should be a byte string and will be
24762476
used as the secret key for an HMAC-based authentication challenge. No
2477-
authentication is done if *authkey* is None.
2477+
authentication is done if *authkey* is ``None``.
24782478
:exc:`~multiprocessing.AuthenticationError` is raised if authentication fails.
24792479
See :ref:`multiprocessing-auth-keys`.
24802480

@@ -2507,9 +2507,9 @@ multiple connections at the same time.
25072507
to the :meth:`~socket.socket.listen` method of the socket once it has been
25082508
bound.
25092509

2510-
If *authkey* is given and not None, it should be a byte string and will be
2510+
If *authkey* is given and not ``None``, it should be a byte string and will be
25112511
used as the secret key for an HMAC-based authentication challenge. No
2512-
authentication is done if *authkey* is None.
2512+
authentication is done if *authkey* is ``None``.
25132513
:exc:`~multiprocessing.AuthenticationError` is raised if authentication fails.
25142514
See :ref:`multiprocessing-auth-keys`.
25152515

Doc/library/os.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ as internal buffering of data.
918918

919919
Copy *count* bytes from file descriptor *src*, starting from offset
920920
*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.
921-
If *offset_src* is None, then *src* is read from the current position;
921+
If *offset_src* is ``None``, then *src* is read from the current position;
922922
respectively for *offset_dst*.
923923

924924
In Linux kernel older than 5.3, the files pointed to by *src* and *dst*
@@ -1664,7 +1664,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16641664
Transfer *count* bytes from file descriptor *src*, starting from offset
16651665
*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.
16661666
At least one of the file descriptors must refer to a pipe. If *offset_src*
1667-
is None, then *src* is read from the current position; respectively for
1667+
is ``None``, then *src* is read from the current position; respectively for
16681668
*offset_dst*. The offset associated to the file descriptor that refers to a
16691669
pipe must be ``None``. The files pointed to by *src* and *dst* must reside in
16701670
the same filesystem, otherwise an :exc:`OSError` is raised with

Doc/library/pathlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ Pure paths provide the following methods and properties:
615615
raise ValueError(error_message.format(str(self), str(formatted)))
616616
ValueError: '/etc/passwd' is not in the subpath of '/usr' OR one path is relative and the other is absolute.
617617

618-
When *walk_up* is False (the default), the path must start with *other*.
619-
When the argument is True, ``..`` entries may be added to form the
618+
When *walk_up* is false (the default), the path must start with *other*.
619+
When the argument is true, ``..`` entries may be added to form the
620620
relative path. In all other cases, such as the paths referencing
621621
different drives, :exc:`ValueError` is raised.::
622622

Doc/library/pickle.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,16 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
314314
map the new Python 3 names to the old module names used in Python 2, so
315315
that the pickle data stream is readable with Python 2.
316316

317-
If *buffer_callback* is None (the default), buffer views are
317+
If *buffer_callback* is ``None`` (the default), buffer views are
318318
serialized into *file* as part of the pickle stream.
319319

320-
If *buffer_callback* is not None, then it can be called any number
320+
If *buffer_callback* is not ``None``, then it can be called any number
321321
of times with a buffer view. If the callback returns a false value
322-
(such as None), the given buffer is :ref:`out-of-band <pickle-oob>`;
322+
(such as ``None``), the given buffer is :ref:`out-of-band <pickle-oob>`;
323323
otherwise the buffer is serialized in-band, i.e. inside the pickle stream.
324324

325-
It is an error if *buffer_callback* is not None and *protocol* is
326-
None or smaller than 5.
325+
It is an error if *buffer_callback* is not ``None`` and *protocol* is
326+
``None`` or smaller than 5.
327327

328328
.. versionchanged:: 3.8
329329
The *buffer_callback* argument was added.
@@ -416,12 +416,12 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
416416
instances of :class:`~datetime.datetime`, :class:`~datetime.date` and
417417
:class:`~datetime.time` pickled by Python 2.
418418

419-
If *buffers* is None (the default), then all data necessary for
419+
If *buffers* is ``None`` (the default), then all data necessary for
420420
deserialization must be contained in the pickle stream. This means
421-
that the *buffer_callback* argument was None when a :class:`Pickler`
421+
that the *buffer_callback* argument was ``None`` when a :class:`Pickler`
422422
was instantiated (or when :func:`dump` or :func:`dumps` was called).
423423

424-
If *buffers* is not None, it should be an iterable of buffer-enabled
424+
If *buffers* is not ``None``, it should be an iterable of buffer-enabled
425425
objects that is consumed each time the pickle stream references
426426
an :ref:`out-of-band <pickle-oob>` buffer view. Such buffers have been
427427
given in order to the *buffer_callback* of a Pickler object.

Doc/library/pyclbr.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Class Objects
142142

143143
.. attribute:: parent
144144

145-
For top-level classes, None. For nested classes, the parent.
145+
For top-level classes, ``None``. For nested classes, the parent.
146146

147147
.. versionadded:: 3.7
148148

Doc/library/statistics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ However, for reading convenience, most of the examples show sorted sequences.
218218
.. function:: harmonic_mean(data, weights=None)
219219

220220
Return the harmonic mean of *data*, a sequence or iterable of
221-
real-valued numbers. If *weights* is omitted or *None*, then
221+
real-valued numbers. If *weights* is omitted or ``None``, then
222222
equal weighting is assumed.
223223

224224
The harmonic mean is the reciprocal of the arithmetic :func:`mean` of the

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ always available.
16841684
contain a tuple of (filename, line number, function name) tuples
16851685
describing the traceback where the coroutine object was created,
16861686
with the most recent call first. When disabled, ``cr_origin`` will
1687-
be None.
1687+
be ``None``.
16881688

16891689
To enable, pass a *depth* value greater than zero; this sets the
16901690
number of frames whose information will be captured. To disable,

Doc/library/test.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ The :mod:`test.support` module defines the following constants:
324324

325325
.. data:: Py_DEBUG
326326

327-
True if Python was built with the :c:macro:`Py_DEBUG` macro
327+
``True`` if Python was built with the :c:macro:`Py_DEBUG` macro
328328
defined, that is, if
329329
Python was :ref:`built in debug mode <debug-build>`.
330330

Doc/library/tkinter.dnd.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Selection of a target object occurs as follows:
2525
#. Top-down search of area under mouse for target widget
2626

2727
* Target widget should have a callable *dnd_accept* attribute
28-
* If *dnd_accept* is not present or returns None, search moves to parent widget
29-
* If no target widget is found, then the target object is None
28+
* If *dnd_accept* is not present or returns ``None``, search moves to parent widget
29+
* If no target widget is found, then the target object is ``None``
3030

3131
2. Call to *<old_target>.dnd_leave(source, event)*
3232
#. Call to *<new_target>.dnd_enter(source, event)*

Doc/library/tty.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The :mod:`tty` module defines the following functions:
5353
is saved before setting *fd* to raw mode; this value is returned.
5454

5555
.. versionchanged:: 3.12
56-
The return value is now the original tty attributes, instead of None.
56+
The return value is now the original tty attributes, instead of ``None``.
5757

5858

5959
.. function:: setcbreak(fd, when=termios.TCSAFLUSH)
@@ -67,7 +67,7 @@ The :mod:`tty` module defines the following functions:
6767
the minimum input to 1 byte with no delay.
6868

6969
.. versionchanged:: 3.12
70-
The return value is now the original tty attributes, instead of None.
70+
The return value is now the original tty attributes, instead of ``None``.
7171

7272
.. versionchanged:: 3.12.2
7373
The ``ICRNL`` flag is no longer cleared. This restores the behavior

0 commit comments

Comments
 (0)