Skip to content

gh-95454: Replace truthy/falsy with true/false #95456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ empty string, all events are passed.

.. method:: filter(record)

Is the specified record to be logged? Returns falsy for no, truthy for
Is the specified record to be logged? Returns false for no, true for
yes. Filters can either modify log records in-place or return a completely
different record instance which will replace the original
log record in any future processing of the event.
Expand Down
12 changes: 6 additions & 6 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,17 +833,17 @@ def filter(self, record):
Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto
this by returning a falsy value.
this by returning a false value.
If a filter attached to a handler returns a log record instance,
then that instance is used in place of the original log record in
any further processing of the event by that handler.
If a filter returns any other truthy value, the original log record
If a filter returns any other true value, the original log record
is used in any further processing of the event by that handler.

If none of the filters return falsy values, this method returns
If none of the filters return false values, this method returns
a log record.
If any of the filters return a falsy value, this method returns
a falsy value.
If any of the filters return a false value, this method returns
a false value.

.. versionchanged:: 3.2

Expand Down Expand Up @@ -1017,7 +1017,7 @@ def handle(self, record):
the I/O thread lock.

Returns an instance of the log record that was emitted
if it passed all filters, otherwise a falsy value is returned.
if it passed all filters, otherwise a false value is returned.
"""
rv = self.filter(record)
if isinstance(rv, LogRecord):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_unittest/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ def testGetSubTestDescriptionWithoutDocstringAndParams(self):
'(' + __name__ + '.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstringAndParams) '
'(<subtest>)')

def testGetSubTestDescriptionForFalsyValues(self):
expected = 'testGetSubTestDescriptionForFalsyValues (%s.Test_TextTestResult.testGetSubTestDescriptionForFalsyValues) [%s]'
def testGetSubTestDescriptionForFalseValues(self):
expected = 'testGetSubTestDescriptionForFalseValues (%s.Test_TextTestResult.testGetSubTestDescriptionForFalseValues) [%s]'
result = unittest.TextTestResult(None, True, 1)
for arg in [0, None, []]:
with self.subTest(arg):
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.5.1rc1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ Kurenkov.
.. nonce: QhQ9RD
.. section: Library

Fixed functools.singledispatch on classes with falsy metaclasses. Patch by
Fixed functools.singledispatch on classes with false metaclasses. Patch by
Ethan Furman.

..
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.5.3rc1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ In the traceback module, restore the formatting of exception messages like
.. nonce: 3UhyPo
.. section: Library

Allow falsy values to be used for msg parameter of subTest().
Allow false values to be used for msg parameter of subTest().

..

Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.6.0b2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ In the traceback module, restore the formatting of exception messages like
.. nonce: 3UhyPo
.. section: Library

Allow falsy values to be used for msg parameter of subTest().
Allow false values to be used for msg parameter of subTest().

..

Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.7.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4453,7 +4453,7 @@ In the traceback module, restore the formatting of exception messages like
.. nonce: 3UhyPo
.. section: Library

Allow falsy values to be used for msg parameter of subTest().
Allow false values to be used for msg parameter of subTest().

..

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replaced incorrectly written true/false values
in documentiation. Patch by Robert O'Shea