Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Feature or enhancement
Proposal:
Since Python 3.12, attempting to use bitwise inversion on a bool type is raises aDeprecationWarning:
Python3.12.4 (main,Jun62024,18:26:44) [Clang15.0.0 (clang-1500.3.9.4)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>a=True>>>~a<stdin>:1:DeprecationWarning:Bitwiseinversion'~'onboolisdeprecated.Thisreturnsthebitwiseinversionoftheunderlyingintobjectandisusuallynotwhatyouexpectfromnegatingabool.Usethe'not'operatorforbooleannegationor~int(x)ifyoureallywantthebitwiseinversionoftheunderlyingint.-2>>>
I have a PR ready.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-122982: Prohibit bitwise inversion on bool type #122983
- gh-122982: Extend the deprecation period for bool inversion by two years #123306
- [3.13] gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306) #123316
- [3.12] gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306) #123317