| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
👍
Sorry, something went wrong.
| * 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.
| 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.
| 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.
Curious if those shouldn't be subtests
Sorry, something went wrong.
|
See https://discuss.python.org/t/bool-deprecation/62232/128 for the context. |
Sorry, something went wrong.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Refs #82012
CC @hauntsaninja, @JelleZijlstra, @gvanrossum who reviewed #103487