Skip to content

Commit 42b619a

Browse files
[3.7] bpo-38738: Fix formatting of True and False. (GH-17083) (GH-17128)
* "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>". (cherry picked from commit 138ccbb)
1 parent eadddad commit 42b619a

38 files changed

+160
-160
lines changed

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ StreamWriter
229229

230230
.. method:: can_write_eof()
231231

232-
Return *True* if the underlying transport supports
233-
the :meth:`write_eof` method, *False* otherwise.
232+
Return ``True`` if the underlying transport supports
233+
the :meth:`write_eof` method, ``False`` otherwise.
234234

235235
.. method:: write_eof()
236236

Doc/library/dataclasses.rst

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

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

388388
.. function:: is_dataclass(class_or_instance)
389389

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

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

Doc/library/difflib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
334334

335335
.. function:: IS_LINE_JUNK(line)
336336

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

341341

342342
.. function:: IS_CHARACTER_JUNK(ch)
343343

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

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

372372
lambda x: x in " \t"

Doc/library/doctest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ OutputChecker objects
15311531

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

Doc/library/email.compat32-message.rst

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ if there is no active state, :exc:`RuntimeError` is raised.
108108

109109
.. function:: isfirstline()
110110

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

114114

115115
.. function:: isstdin()
116116

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

120120

121121
.. function:: nextfile()

Doc/library/functions.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ are always available. They are listed here in alphabetical order.
178178
.. function:: callable(object)
179179

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

@@ -777,19 +777,19 @@ are always available. They are listed here in alphabetical order.
777777

778778
.. function:: isinstance(object, classinfo)
779779

780-
Return true if the *object* argument is an instance of the *classinfo*
780+
Return ``True`` if the *object* argument is an instance of the *classinfo*
781781
argument, or of a (direct, indirect or :term:`virtual <abstract base
782782
class>`) subclass thereof. If *object* is not
783-
an object of the given type, the function always returns false.
783+
an object of the given type, the function always returns ``False``.
784784
If *classinfo* is a tuple of type objects (or recursively, other such
785-
tuples), return true if *object* is an instance of any of the types.
785+
tuples), return ``True`` if *object* is an instance of any of the types.
786786
If *classinfo* is not a type or tuple of types and such tuples,
787787
a :exc:`TypeError` exception is raised.
788788

789789

790790
.. function:: issubclass(class, classinfo)
791791

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

Doc/library/gc.rst

Lines changed: 1 addition & 1 deletion
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/http.cookiejar.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ methods:
369369

370370
.. method:: CookiePolicy.domain_return_ok(domain, request)
371371

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

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

394394
.. method:: CookiePolicy.path_return_ok(path, request)
395395

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

398398
See the documentation for :meth:`domain_return_ok`.
399399

@@ -702,7 +702,7 @@ accessed using the following methods:
702702

703703
.. method:: Cookie.has_nonstandard_attr(name)
704704

705-
Return true if cookie has the named cookie-attribute.
705+
Return ``True`` if cookie has the named cookie-attribute.
706706

707707

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

Doc/library/importlib.rst

Lines changed: 1 addition & 1 deletion
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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,55 +273,55 @@ attributes:
273273

274274
.. function:: ismodule(object)
275275

276-
Return true if the object is a module.
276+
Return ``True`` if the object is a module.
277277

278278

279279
.. function:: isclass(object)
280280

281-
Return true if the object is a class, whether built-in or created in Python
281+
Return ``True`` if the object is a class, whether built-in or created in Python
282282
code.
283283

284284

285285
.. function:: ismethod(object)
286286

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

289289

290290
.. function:: isfunction(object)
291291

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

295295

296296
.. function:: isgeneratorfunction(object)
297297

298-
Return true if the object is a Python generator function.
298+
Return ``True`` if the object is a Python generator function.
299299

300300

301301
.. function:: isgenerator(object)
302302

303-
Return true if the object is a generator.
303+
Return ``True`` if the object is a generator.
304304

305305

306306
.. function:: iscoroutinefunction(object)
307307

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

311311
.. versionadded:: 3.5
312312

313313

314314
.. function:: iscoroutine(object)
315315

316-
Return true if the object is a :term:`coroutine` created by an
316+
Return ``True`` if the object is a :term:`coroutine` created by an
317317
:keyword:`async def` function.
318318

319319
.. versionadded:: 3.5
320320

321321

322322
.. function:: isawaitable(object)
323323

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

326326
Can also be used to distinguish generator-based coroutines from regular
327327
generators::
@@ -340,7 +340,7 @@ attributes:
340340

341341
.. function:: isasyncgenfunction(object)
342342

343-
Return true if the object is an :term:`asynchronous generator` function,
343+
Return ``True`` if the object is an :term:`asynchronous generator` function,
344344
for example::
345345

346346
>>> async def agen():
@@ -354,44 +354,44 @@ attributes:
354354

355355
.. function:: isasyncgen(object)
356356

357-
Return true if the object is an :term:`asynchronous generator iterator`
357+
Return ``True`` if the object is an :term:`asynchronous generator iterator`
358358
created by an :term:`asynchronous generator` function.
359359

360360
.. versionadded:: 3.6
361361

362362
.. function:: istraceback(object)
363363

364-
Return true if the object is a traceback.
364+
Return ``True`` if the object is a traceback.
365365

366366

367367
.. function:: isframe(object)
368368

369-
Return true if the object is a frame.
369+
Return ``True`` if the object is a frame.
370370

371371

372372
.. function:: iscode(object)
373373

374-
Return true if the object is a code.
374+
Return ``True`` if the object is a code.
375375

376376

377377
.. function:: isbuiltin(object)
378378

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

381381

382382
.. function:: isroutine(object)
383383

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

386386

387387
.. function:: isabstract(object)
388388

389-
Return true if the object is an abstract base class.
389+
Return ``True`` if the object is an abstract base class.
390390

391391

392392
.. function:: ismethoddescriptor(object)
393393

394-
Return true if the object is a method descriptor, but not if
394+
Return ``True`` if the object is a method descriptor, but not if
395395
:func:`ismethod`, :func:`isclass`, :func:`isfunction` or :func:`isbuiltin`
396396
are true.
397397

@@ -402,14 +402,14 @@ attributes:
402402
sensible, and :attr:`__doc__` often is.
403403

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

409409

410410
.. function:: isdatadescriptor(object)
411411

412-
Return true if the object is a data descriptor.
412+
Return ``True`` if the object is a data descriptor.
413413

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

423423
.. function:: isgetsetdescriptor(object)
424424

425-
Return true if the object is a getset descriptor.
425+
Return ``True`` if the object is a getset descriptor.
426426

427427
.. impl-detail::
428428

@@ -433,7 +433,7 @@ attributes:
433433

434434
.. function:: ismemberdescriptor(object)
435435

436-
Return true if the object is a member descriptor.
436+
Return ``True`` if the object is a member descriptor.
437437

438438
.. impl-detail::
439439

Doc/library/ipaddress.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ dictionaries.
557557

558558
.. method:: subnet_of(other)
559559

560-
Returns *True* if this network is a subnet of *other*.
560+
Return ``True`` if this network is a subnet of *other*.
561561

562562
>>> a = ip_network('192.168.1.0/24')
563563
>>> b = ip_network('192.168.1.128/30')
@@ -568,7 +568,7 @@ dictionaries.
568568

569569
.. method:: supernet_of(other)
570570

571-
Returns *True* if this network is a supernet of *other*.
571+
Return ``True`` if this network is a supernet of *other*.
572572

573573
>>> a = ip_network('192.168.1.0/24')
574574
>>> b = ip_network('192.168.1.128/30')

Doc/library/keyword.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This module allows a Python program to determine if a string is a keyword.
1313

1414
.. function:: iskeyword(s)
1515

16-
Return true if *s* is a Python keyword.
16+
Return ``True`` if *s* is a Python keyword.
1717

1818

1919
.. data:: kwlist

0 commit comments

Comments
 (0)