FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

@final class without __bool__ cannot have falsey instances by ikonst · Pull Request #16566 · python/mypy · GitHub

Repository navigation

@final class without __bool__ cannot have falsey instances - #16566

Merged
hauntsaninja merged 5 commits into
python:masterfrom
ikonst:final-never-false
Dec 4, 2023
Merged

hauntsaninja merged 5 commits into
python:masterfrom
ikonst:final-never-false

Conversation

ikonst commented Nov 26, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor

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.

Comment thread test-data/unit/check-final.test Outdated

This comment has been minimized.

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

Copy link
Copy Markdown
Contributor

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

hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice!

hauntsaninja merged commit 7c33e7c into python:master Dec 4, 2023
ikonst deleted the final-never-false branch December 4, 2023 20:10

KotlinIsland commented Jan 4, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor

This file contains hidden or 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
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.

4 participants


Back | FazBrowse Home | New Git URL