GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-149532: Remove `bool.__invert__` magic method by sobolevn · Pull Request #149533 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented May 8, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Refs #82012

CC @hauntsaninja, @JelleZijlstra, @gvanrossum who reviewed #103487

  • Issue: Remove bool.__invert__ for 3.16 #149532

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
pythongh-149532: Remove bool.__invert__ magic method
d01f243
@sobolevn
sobolevn requested a review from AA-Turner as a code owner May 8, 2026 04:46
@bedevere-app bedevere-app Bot mentioned this pull request May 8, 2026
Remove bool.__invert__ for 3.16 #149532
Open
@bedevere-app bedevere-app Bot added the awaiting core review label May 8, 2026
sergey-miryanov
sergey-miryanov approved these changes May 8, 2026
View reviewed changes

@sergey-miryanov sergey-miryanov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
johnslavik
johnslavik reviewed May 8, 2026
View reviewed changes
Comment thread Doc/whatsnew/3.16.rst
* Bitwise inversion on boolean types, ``~True`` or ``~False``
has been deprecated since Python 3.12,
as it produces surprising and unintuitive results (``-2`` and ``-1``).
Use ``not x`` instead for the logical negation of a Boolean.

@johnslavik johnslavik May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
Use ``not x`` instead for the logical negation of a Boolean.
Use ``not x`` instead for the logical negation of a boolean.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_bool.py
Comment on lines +160 to +175
msg = re.escape("bad operand type for unary ~: 'bool'")

# Check constants in case of a folding:
with self.assertRaisesRegex(TypeError, msg):
~False
with self.assertRaisesRegex(TypeError, msg):
~True

# Check variable:
for bool_val in [True, False]:
with self.subTest(bool_val), self.assertRaisesRegex(TypeError, msg):
~bool_val

# Check `eval`:
with self.assertRaisesRegex(TypeError, msg):
eval("~False")

@johnslavik johnslavik May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Curious if those shouldn't be subtests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn sobolevn added the DO-NOT-MERGE label May 9, 2026
@sobolevn

sobolevn commented May 9, 2026

Copy link
Copy Markdown
Member Author

See https://discuss.python.org/t/bool-deprecation/62232/128 for the context.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@johnslavik johnslavik johnslavik left review comments
@sergey-miryanov sergey-miryanov sergey-miryanov approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review DO-NOT-MERGE stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sobolevn @sergey-miryanov @johnslavik
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.