122982 Instant

For most developers, this is rarely the intended result. Usually, someone using ~ on a boolean actually wants the logical NOT ( not True ), which correctly returns False . Because of this common point of confusion, the Python steering committee decided to deprecate bitwise inversion on booleans to encourage clearer coding practices. What’s New in Issue #122982?

Keep an eye on your console for those DeprecationWarnings —they are there to help you stay ahead of the curve! 122982

If your project currently triggers a DeprecationWarning when using ~ on a boolean, the fix is straightforward. Replace the bitwise operator with the logical not keyword: For most developers, this is rarely the intended result

Python’s evolution is often about making the "obvious" way to do things the only way to do things. While Issue #122982 might seem like a minor administrative tweak in the CPython GitHub, it reflects the core philosophy of maintaining a stable, readable, and developer-friendly language. What’s New in Issue #122982

This blog post addresses in the CPython repository, which focuses on extending the deprecation warning period for bitwise inversion on boolean types in Python.

Originally, the plan was to move toward a full error or a more aggressive deprecation schedule. However, Issue #122982 proposes . This extension serves a few key purposes: