Change final classes without __bool__ method to always be True#12187
Change final classes without __bool__ method to always be True#12187BolunThompson wants to merge 4 commits intopython:masterfrom
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: rich (https://github.com/willmcgugan/rich)
+ rich/spinner.py:83: error: Statement is unreachable
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/tokenize.py:603:29: error: Right operand of "or" is never evaluated
|
sobolevn
left a comment
There was a problem hiding this comment.
Thank you.
Please, also take a look at:
- rich/spinner.py:83: error: Statement is unreachable
It looks like a false positive. Because not self.text is possible when self.text == ''
| assert fo.items[0].can_be_false | ||
| assert fo.items[1] is tup_type | ||
|
|
||
| def test_false_only_of_truthy_type_is_uninhabited(self) -> None: |
There was a problem hiding this comment.
I think that it will be more useful to add tests to some check-*.test file.
I think that these ones can be removed.
|
The Black change is also a false positive. It's checking a member of this dict: https://github.com/psf/black/blob/main/src/blib2to3/pgen2/tokenize.py#L159 But the members of that dict can be None, so it's legitimate to look at |
|
I'm too busy to work on this now, so anybody can finish this. If I remember correctly one of the errors related to my PR was not handling Union types correctly; I don't remember the cause of the other error. |
Description
Closes #12158
Changes it so that final classes without a
__bool__or__len__method are always True.Test Plan
Tests are added to test/testtypes.py