GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-149532: Remove `bool.__invert__` magic method by sobolevn · Pull Request #149533 · python/cpython Conversation
|
| * 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. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| 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.
There was an error while loading. Please reload this page.
| 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") |
There was a problem 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.
There was an error while loading. Please reload this page.
|
See https://discuss.python.org/t/bool-deprecation/62232/128 for the context. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.