@final class without __bool__ cannot have falsey instances by ikonst · Pull Request #16566 · python/mypy
Navigation Menu
{{ message }}
- Notifications You must be signed in to change notification settings
- Fork 3.2k
Merged
hauntsaninja merged 5 commits intopython:masterfrom
Dec 4, 2023Merged
@final class without __bool__ cannot have falsey instances#16566
hauntsaninja merged 5 commits intopython:masterfrom
@final class without __bool__ cannot have falsey instances#16566
hauntsaninja merged 5 commits intopython:masterfrom
Conversation
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.
ikonst
mentioned this pull request
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ikonst and others added 2 commits
November 27, 2023 10:48for more information, see https://pre-commit.ci
AlexWaygood reviewed Nov 27, 2023
test-data/unit/check-final.test
Outdated
Show resolved
Hide resolved
test-data/unit/check-final.test Outdated Show resolved Hide resolved
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link Copy Markdown
Contributor
github-actions
bot
commented
Nov 27, 2023
github-actions bot commented
Nov 27, 2023According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
hauntsaninja approved these changes Dec 4, 2023
Copy link Copy Markdown
Collaborator
hauntsaninja
left a comment
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
merged commit
7c33e7c
into
python:master
ikonst
deleted the
final-never-false
branch
hauntsaninja
mentioned this pull request
Copy link Copy Markdown
Contributor
KotlinIsland
mentioned this pull request
QuLogic
mentioned this pull request
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