-
-
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
bool/int substitutions are valid only sometimes: x, y = False, True # type int, int #1757
Comments
I don't think this is a bug. In Python, because x = True
print(isinstance(x, int)) # True
x = 0
print(isinstance(x, bool)) # False |
Indeed, I think the OP is confused by Python's accepting |
I can see the reasoning, that because I was talking about how in python, these examples are equivalent:
I just thought mypy would be a little stricter, and say that |
@cjwelborn people aren't notified of comments after an issue is closed. If you want them to notice you have to @mention them like I did in this message. |
@0ion9, thanks. I should have done that. |
An integer or no argument is supposed to be passed. These weren't caught by mypy because booleans are integers in python, see python/mypy#1757
An integer or no argument is supposed to be passed. These weren't caught by mypy because booleans are integers in python, see python/mypy#1757
An integer or no argument is supposed to be passed. These weren't caught by mypy because booleans are integers in python, see python/mypy#1757
Like the title says, this is okay in mypy:
But the reverse is not:
I first found it checking to see if mypy cares about
bool
/int
where Python itself doesn't.Python is okay with this because
bool
sub-classesint
, and mixed arithmetic is okay:mypy doesn't seem to care about this:
..but it cares about the opposite:
Is this an actual bug, or is this documented somewhere? I know why Python does it, I just thought that mypy would say something about it.
The text was updated successfully, but these errors were encountered: