-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Change final classes without __bool__ method to always be True #12187
base: master
Are you sure you want to change the base?
Change final classes without __bool__ method to always be True #12187
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 == ''
@@ -451,6 +459,13 @@ def test_false_only_of_union(self) -> None: | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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