Skip to content

Commit 138ccbb

Browse files
bpo-38738: Fix formatting of True and False. (GH-17083)
* "Return true/false" is replaced with "Return ``True``/``False``" if the function actually returns a bool. * Fixed formatting of some True and False literals (now in monospace). * Replaced "True/False" with "true/false" if it can be not only bool. * Replaced some 1/0 with True/False if it corresponds the code. * "Returns <bool>" is replaced with "Return <bool>".
1 parent 9a13a38 commit 138ccbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+176
-176
lines changed

Doc/library/asyncio-stream.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ StreamWriter
263263

264264
.. method:: can_write_eof()
265265

266-
Return *True* if the underlying transport supports
267-
the :meth:`write_eof` method, *False* otherwise.
266+
Return ``True`` if the underlying transport supports
267+
the :meth:`write_eof` method, ``False`` otherwise.
268268

269269
.. method:: write_eof()
270270

Doc/library/dataclasses.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Module-level decorators, classes, and functions
153153
method of the superclass will be used (if the superclass is
154154
:class:`object`, this means it will fall back to id-based hashing).
155155

156-
- ``frozen``: If true (the default is False), assigning to fields will
156+
- ``frozen``: If true (the default is ``False``), assigning to fields will
157157
generate an exception. This emulates read-only frozen instances. If
158158
:meth:`__setattr__` or :meth:`__delattr__` is defined in the class, then
159159
:exc:`TypeError` is raised. See the discussion below.
@@ -386,8 +386,8 @@ Module-level decorators, classes, and functions
386386

387387
.. function:: is_dataclass(class_or_instance)
388388

389-
Returns True if its parameter is a dataclass or an instance of one,
390-
otherwise returns False.
389+
Return ``True`` if its parameter is a dataclass or an instance of one,
390+
otherwise return ``False``.
391391

392392
If you need to know if a class is an instance of a dataclass (and
393393
not a dataclass itself), then add a further check for ``not

Doc/library/dialog.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ listed below:
7373
7474
| *defaultextension* - default extension to append to file (save dialogs)
7575
76-
| *multiple* - when True, selection of multiple items is allowed
76+
| *multiple* - when true, selection of multiple items is allowed
7777
7878

7979
**Static factory functions**
@@ -227,4 +227,4 @@ is the base class for dialogs defined in other supporting modules.
227227

228228
.. seealso::
229229

230-
Modules :mod:`tkinter.messagebox`, :ref:`tut-files`
230+
Modules :mod:`tkinter.messagebox`, :ref:`tut-files`

Doc/library/difflib.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
338338

339339
.. function:: IS_LINE_JUNK(line)
340340

341-
Return true for ignorable lines. The line *line* is ignorable if *line* is
341+
Return ``True`` for ignorable lines. The line *line* is ignorable if *line* is
342342
blank or contains a single ``'#'``, otherwise it is not ignorable. Used as a
343343
default for parameter *linejunk* in :func:`ndiff` in older versions.
344344

345345

346346
.. function:: IS_CHARACTER_JUNK(ch)
347347

348-
Return true for ignorable characters. The character *ch* is ignorable if *ch*
348+
Return ``True`` for ignorable characters. The character *ch* is ignorable if *ch*
349349
is a space or tab, otherwise it is not ignorable. Used as a default for
350350
parameter *charjunk* in :func:`ndiff`.
351351

@@ -370,7 +370,7 @@ The :class:`SequenceMatcher` class has this constructor:
370370
Optional argument *isjunk* must be ``None`` (the default) or a one-argument
371371
function that takes a sequence element and returns true if and only if the
372372
element is "junk" and should be ignored. Passing ``None`` for *isjunk* is
373-
equivalent to passing ``lambda x: 0``; in other words, no elements are ignored.
373+
equivalent to passing ``lambda x: False``; in other words, no elements are ignored.
374374
For example, pass::
375375

376376
lambda x: x in " \t"

Doc/library/doctest.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ OutputChecker objects
15291529

15301530
A class used to check the whether the actual output from a doctest example
15311531
matches the expected output. :class:`OutputChecker` defines two methods:
1532-
:meth:`check_output`, which compares a given pair of outputs, and returns true
1532+
:meth:`check_output`, which compares a given pair of outputs, and returns ``True``
15331533
if they match; and :meth:`output_difference`, which returns a string describing
15341534
the differences between two outputs.
15351535

Doc/library/email.compat32-message.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ Here are the methods of the :class:`Message` class:
308308

309309
.. method:: __contains__(name)
310310

311-
Return true if the message object has a field named *name*. Matching is
311+
Return ``True`` if the message object has a field named *name*. Matching is
312312
done case-insensitively and *name* should not include the trailing colon.
313313
Used for the ``in`` operator, e.g.::
314314

Doc/library/email.errors.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ All defect classes are subclassed from :class:`email.errors.MessageDefect`.
9999
* :class:`MultipartInvariantViolationDefect` -- A message claimed to be a
100100
:mimetype:`multipart`, but no subparts were found. Note that when a message
101101
has this defect, its :meth:`~email.message.Message.is_multipart` method may
102-
return false even though its content type claims to be :mimetype:`multipart`.
102+
return ``False`` even though its content type claims to be :mimetype:`multipart`.
103103

104104
* :class:`InvalidBase64PaddingDefect` -- When decoding a block of base64
105105
encoded bytes, the padding was not correct. Enough padding is added to

Doc/library/email.message.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ message objects.
178178

179179
.. method:: __contains__(name)
180180

181-
Return true if the message object has a field named *name*. Matching is
181+
Return ``True`` if the message object has a field named *name*. Matching is
182182
done without regard to case and *name* does not include the trailing
183183
colon. Used for the ``in`` operator. For example::
184184

Doc/library/fileinput.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ if there is no active state, :exc:`RuntimeError` is raised.
109109

110110
.. function:: isfirstline()
111111

112-
Returns true if the line just read is the first line of its file, otherwise
113-
returns false.
112+
Return ``True`` if the line just read is the first line of its file, otherwise
113+
return ``False``.
114114

115115

116116
.. function:: isstdin()
117117

118-
Returns true if the last line was read from ``sys.stdin``, otherwise returns
119-
false.
118+
Return ``True`` if the last line was read from ``sys.stdin``, otherwise return
119+
``False``.
120120

121121

122122
.. function:: nextfile()

Doc/library/functions.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ are always available. They are listed here in alphabetical order.
181181
.. function:: callable(object)
182182

183183
Return :const:`True` if the *object* argument appears callable,
184-
:const:`False` if not. If this returns true, it is still possible that a
185-
call fails, but if it is false, calling *object* will never succeed.
184+
:const:`False` if not. If this returns ``True``, it is still possible that a
185+
call fails, but if it is ``False``, calling *object* will never succeed.
186186
Note that classes are callable (calling a class returns a new instance);
187187
instances are callable if their class has a :meth:`__call__` method.
188188

@@ -840,19 +840,19 @@ are always available. They are listed here in alphabetical order.
840840

841841
.. function:: isinstance(object, classinfo)
842842

843-
Return true if the *object* argument is an instance of the *classinfo*
843+
Return ``True`` if the *object* argument is an instance of the *classinfo*
844844
argument, or of a (direct, indirect or :term:`virtual <abstract base
845845
class>`) subclass thereof. If *object* is not
846-
an object of the given type, the function always returns false.
846+
an object of the given type, the function always returns ``False``.
847847
If *classinfo* is a tuple of type objects (or recursively, other such
848-
tuples), return true if *object* is an instance of any of the types.
848+
tuples), return ``True`` if *object* is an instance of any of the types.
849849
If *classinfo* is not a type or tuple of types and such tuples,
850850
a :exc:`TypeError` exception is raised.
851851

852852

853853
.. function:: issubclass(class, classinfo)
854854

855-
Return true if *class* is a subclass (direct, indirect or :term:`virtual
855+
Return ``True`` if *class* is a subclass (direct, indirect or :term:`virtual
856856
<abstract base class>`) of *classinfo*. A
857857
class is considered a subclass of itself. *classinfo* may be a tuple of class
858858
objects, in which case every entry in *classinfo* will be checked. In any other

Doc/library/gc.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The :mod:`gc` module provides the following functions:
3535

3636
.. function:: isenabled()
3737

38-
Returns true if automatic collection is enabled.
38+
Return ``True`` if automatic collection is enabled.
3939

4040

4141
.. function:: collect(generation=2)

Doc/library/hashlib.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ library that Python uses on your platform. On most platforms the
8282

8383
.. versionchanged:: 3.9
8484
All hashlib constructors take a keyword-only argument *usedforsecurity*
85-
with default value *True*. A false value allows the use of insecure and
86-
blocked hashing algorithms in restricted environments. *False* indicates
85+
with default value ``True``. A false value allows the use of insecure and
86+
blocked hashing algorithms in restricted environments. ``False`` indicates
8787
that the hashing algorithm is not used in a security context, e.g. as a
8888
non-cryptographic one-way compression function.
8989

Doc/library/http.cookiejar.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ methods:
378378

379379
.. method:: CookiePolicy.domain_return_ok(domain, request)
380380

381-
Return false if cookies should not be returned, given cookie domain.
381+
Return ``False`` if cookies should not be returned, given cookie domain.
382382

383383
This method is an optimization. It removes the need for checking every cookie
384384
with a particular domain (which might involve reading many files). Returning
@@ -402,7 +402,7 @@ methods:
402402

403403
.. method:: CookiePolicy.path_return_ok(path, request)
404404

405-
Return false if cookies should not be returned, given cookie path.
405+
Return ``False`` if cookies should not be returned, given cookie path.
406406

407407
See the documentation for :meth:`domain_return_ok`.
408408

@@ -711,7 +711,7 @@ accessed using the following methods:
711711

712712
.. method:: Cookie.has_nonstandard_attr(name)
713713

714-
Return true if cookie has the named cookie-attribute.
714+
Return ``True`` if cookie has the named cookie-attribute.
715715

716716

717717
.. method:: Cookie.get_nonstandard_attr(name, default=None)

Doc/library/importlib.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ find and load modules.
11681168

11691169
.. method:: is_package(fullname)
11701170

1171-
Return true if :attr:`path` appears to be for a package.
1171+
Return ``True`` if :attr:`path` appears to be for a package.
11721172

11731173
.. method:: path_stats(path)
11741174

Doc/library/inspect.rst

+25-25
Original file line numberDiff line numberDiff line change
@@ -277,63 +277,63 @@ attributes:
277277

278278
.. function:: ismodule(object)
279279

280-
Return true if the object is a module.
280+
Return ``True`` if the object is a module.
281281

282282

283283
.. function:: isclass(object)
284284

285-
Return true if the object is a class, whether built-in or created in Python
285+
Return ``True`` if the object is a class, whether built-in or created in Python
286286
code.
287287

288288

289289
.. function:: ismethod(object)
290290

291-
Return true if the object is a bound method written in Python.
291+
Return ``True`` if the object is a bound method written in Python.
292292

293293

294294
.. function:: isfunction(object)
295295

296-
Return true if the object is a Python function, which includes functions
296+
Return ``True`` if the object is a Python function, which includes functions
297297
created by a :term:`lambda` expression.
298298

299299

300300
.. function:: isgeneratorfunction(object)
301301

302-
Return true if the object is a Python generator function.
302+
Return ``True`` if the object is a Python generator function.
303303

304304
.. versionchanged:: 3.8
305-
Functions wrapped in :func:`functools.partial` now return true if the
305+
Functions wrapped in :func:`functools.partial` now return ``True`` if the
306306
wrapped function is a Python generator function.
307307

308308

309309
.. function:: isgenerator(object)
310310

311-
Return true if the object is a generator.
311+
Return ``True`` if the object is a generator.
312312

313313

314314
.. function:: iscoroutinefunction(object)
315315

316-
Return true if the object is a :term:`coroutine function`
316+
Return ``True`` if the object is a :term:`coroutine function`
317317
(a function defined with an :keyword:`async def` syntax).
318318

319319
.. versionadded:: 3.5
320320

321321
.. versionchanged:: 3.8
322-
Functions wrapped in :func:`functools.partial` now return true if the
322+
Functions wrapped in :func:`functools.partial` now return ``True`` if the
323323
wrapped function is a :term:`coroutine function`.
324324

325325

326326
.. function:: iscoroutine(object)
327327

328-
Return true if the object is a :term:`coroutine` created by an
328+
Return ``True`` if the object is a :term:`coroutine` created by an
329329
:keyword:`async def` function.
330330

331331
.. versionadded:: 3.5
332332

333333

334334
.. function:: isawaitable(object)
335335

336-
Return true if the object can be used in :keyword:`await` expression.
336+
Return ``True`` if the object can be used in :keyword:`await` expression.
337337

338338
Can also be used to distinguish generator-based coroutines from regular
339339
generators::
@@ -352,7 +352,7 @@ attributes:
352352

353353
.. function:: isasyncgenfunction(object)
354354

355-
Return true if the object is an :term:`asynchronous generator` function,
355+
Return ``True`` if the object is an :term:`asynchronous generator` function,
356356
for example::
357357

358358
>>> async def agen():
@@ -364,50 +364,50 @@ attributes:
364364
.. versionadded:: 3.6
365365

366366
.. versionchanged:: 3.8
367-
Functions wrapped in :func:`functools.partial` now return true if the
367+
Functions wrapped in :func:`functools.partial` now return ``True`` if the
368368
wrapped function is a :term:`asynchronous generator` function.
369369

370370

371371
.. function:: isasyncgen(object)
372372

373-
Return true if the object is an :term:`asynchronous generator iterator`
373+
Return ``True`` if the object is an :term:`asynchronous generator iterator`
374374
created by an :term:`asynchronous generator` function.
375375

376376
.. versionadded:: 3.6
377377

378378
.. function:: istraceback(object)
379379

380-
Return true if the object is a traceback.
380+
Return ``True`` if the object is a traceback.
381381

382382

383383
.. function:: isframe(object)
384384

385-
Return true if the object is a frame.
385+
Return ``True`` if the object is a frame.
386386

387387

388388
.. function:: iscode(object)
389389

390-
Return true if the object is a code.
390+
Return ``True`` if the object is a code.
391391

392392

393393
.. function:: isbuiltin(object)
394394

395-
Return true if the object is a built-in function or a bound built-in method.
395+
Return ``True`` if the object is a built-in function or a bound built-in method.
396396

397397

398398
.. function:: isroutine(object)
399399

400-
Return true if the object is a user-defined or built-in function or method.
400+
Return ``True`` if the object is a user-defined or built-in function or method.
401401

402402

403403
.. function:: isabstract(object)
404404

405-
Return true if the object is an abstract base class.
405+
Return ``True`` if the object is an abstract base class.
406406

407407

408408
.. function:: ismethoddescriptor(object)
409409

410-
Return true if the object is a method descriptor, but not if
410+
Return ``True`` if the object is a method descriptor, but not if
411411
:func:`ismethod`, :func:`isclass`, :func:`isfunction` or :func:`isbuiltin`
412412
are true.
413413

@@ -418,14 +418,14 @@ attributes:
418418
sensible, and :attr:`__doc__` often is.
419419

420420
Methods implemented via descriptors that also pass one of the other tests
421-
return false from the :func:`ismethoddescriptor` test, simply because the
421+
return ``False`` from the :func:`ismethoddescriptor` test, simply because the
422422
other tests promise more -- you can, e.g., count on having the
423423
:attr:`__func__` attribute (etc) when an object passes :func:`ismethod`.
424424

425425

426426
.. function:: isdatadescriptor(object)
427427

428-
Return true if the object is a data descriptor.
428+
Return ``True`` if the object is a data descriptor.
429429

430430
Data descriptors have both a :attr:`~object.__get__` and a :attr:`~object.__set__` method.
431431
Examples are properties (defined in Python), getsets, and members. The
@@ -438,7 +438,7 @@ attributes:
438438

439439
.. function:: isgetsetdescriptor(object)
440440

441-
Return true if the object is a getset descriptor.
441+
Return ``True`` if the object is a getset descriptor.
442442

443443
.. impl-detail::
444444

@@ -449,7 +449,7 @@ attributes:
449449

450450
.. function:: ismemberdescriptor(object)
451451

452-
Return true if the object is a member descriptor.
452+
Return ``True`` if the object is a member descriptor.
453453

454454
.. impl-detail::
455455

0 commit comments

Comments
 (0)