-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect truthyness for Enum types and literals (#17337)
Fixes: #17333 This ensures `can_be_true` and `can_be_false` on enum literals depends on the specific `Enum` fallback type behind the `Literal`, since `__bool__` can be overriden like on any other type. Additionally typeops `true_only` and `false_only` now respect the metaclass when looking up the return values of `__bool__` and `__len__`, which ensures that a default `Enum` that doesn't override `__bool__` is still considered always truthy.
- Loading branch information
Showing
15 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.