It allows more time for the community to discuss if there are specific edge cases where bitwise inversion on bool remains necessary. How to Prepare Your Code
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 . 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. It allows more time for the community to
If you have ever accidentally used the bitwise inversion operator ( ~ ) on a Python boolean, you might have noticed it behaves in a way that is technically correct but logically confusing. As Python continues to refine its syntax for better clarity, Issue #122982 marks a small but important step in how the language handles these edge cases. The Problem: Why ~True Isn't False ~False (which is ~0 ) evaluates to -1
Python Development Update: Extending the Deprecation Warning for ~bool (Issue #122982)
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: