122982 -

In Python, booleans are a subclass of integers. When you apply the bitwise NOT operator ( ~ ) to a boolean: ~True (which is ~1 ) evaluates to -2 . ~False (which is ~0 ) evaluates to -1 .

Rapidly turning a warning into a hard error can break environments. A longer warning period ensures developers see the notice without their builds immediately failing. 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: In Python, booleans are a subclass of integers

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? Rapidly turning a warning into a hard error

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: