Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@final class without __bool__ cannot have falsey instances #16566

Merged
merged 5 commits into from Dec 4, 2023

Conversation

ikonst
Copy link
Contributor

@ikonst ikonst commented Nov 26, 2023

Once class C is final, we know that a derived class won't add a __bool__ or a __len__ so if they're missing, we can assume every instance of C to be truthy.

Relates to #16565.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@hauntsaninja hauntsaninja merged commit 7c33e7c into python:master Dec 4, 2023
18 checks passed
@ikonst ikonst deleted the final-never-false branch December 4, 2023 20:10
@KotlinIsland
Copy link
Contributor

KotlinIsland commented Jan 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants