8000 gh-82012: Deprecate bitwise inversion (~) of bool by timhoffm · Pull Request #103487 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-82012: Deprecate bitwise inversion (~) of bool #103487

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 5 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move section "Boolean Values" into "Boolean Type"
  • Loading branch information
timhoffm committed May 1, 2023
commit 2cbfe2da9c7a7c778ca18e01b0ac9225c119eca7
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ are always available. They are listed here in alphabetical order.
or omitted, this returns ``False``; otherwise, it returns ``True``. The
:class:`bool` class is a subclass of :class:`int` (see :ref:`typesnumeric`).
It cannot be subclassed further. Its only instances are ``False`` and
``True`` (see :ref:`bltin-boolean-values`).
``True`` (see :ref:`typebool`).

.. index:: pair: Boolean; type

Expand Down
33 changes: 13 additions & 20 deletions Doc/library/stdtypes.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -808,19 +808,26 @@ Boolean Type - :class:`bool`
============================

Booleans represent truth values. The :class:`bool` type has exactly two
constant instances ``True`` and ``False``.
constant instances: ``True`` and ``False``.

Other types can be cast to bool explicitly using the function :func:`bool`.
Additionally, they are implicitly interpreted as bool in some contexts - see
:ref:`truth`.
.. index::
single: False
single: True
pair: Boolean; values

The built-in function :func:`bool` converts any value to a boolean, if the
value can be interpreted as a truth value (see section :ref:`truth` above).

For logical operations, use the :ref:`boolean operators <boolean>` ``and``,
``or`` and ``not``.
When applying the bitwise operators ``&``, ``|``, ``^`` to two booleans, they
return a bool equivalent to the logical operations "and", "or", "xor". Still,
for ``&`` and ``|``, the logical operators ``and`` and ``or`` are preferred.
The use of the bitwise inversion operator ``~`` is deprecated and will raise
an error in Python 3.14.

.. deprecated:: 3.12

The use of the bitwise inversion operator ``~`` is deprecated and will
raise an error in Python 3.14.

:class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In
many numeric contexts, bools behave like the integers 0 and 1, respectively.
Expand Down Expand Up @@ -5419,20 +5426,6 @@ information. There is exactly one ``NotImplemented`` object.
It is written as ``NotImplemented``.


.. _bltin-boolean-values:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. The removal of this ref tag broke intersphinx downstream. I have not tracked down yet which middleware is calling this tag when API docstring has a "bool" mentioned. I suspect it is numpydoc. Is it not possible to reuse this tag for your new section above?

xref astropy/astropy#15428

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you open a PR, I can backport it to the 3.12 branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Please see #110371 . Thank you for your consideration!


Boolean Values
--------------

Boolean values are the two constant objects ``False`` and ``True``. See
:ref:`typebool` for more info.

.. index::
single: False
single: True
pair: Boolean; values


.. _typesinternal:

Internal Objects
Expand Down
0