Skip to content

Operations on None should fall back to object #1766

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

Closed
rwbarton opened this issue Jun 29, 2016 · 2 comments · Fixed by #1836
Closed

Operations on None should fall back to object #1766

rwbarton opened this issue Jun 29, 2016 · 2 comments · Fixed by #1836
Labels
bug mypy got something wrong topic-strict-optional

Comments

@rwbarton
Copy link
Contributor

rwbarton@morphism:~/mypy$ python3 -m mypy --strict-optional -c 'None == None'
<string>:1: error: Unsupported left operand type for == (None)
rwbarton@morphism:~/mypy$ python3 -m mypy --strict-optional -c 'str(None)'
<string>:1: error: No overload variant of "str" matches argument types [builtins.None]

These should not be errors, as the type of None is a subtype of object.

@ddfisher ddfisher changed the title Operations on None should fall back to object None should be a subtype of object Jun 30, 2016
@ddfisher ddfisher added the bug mypy got something wrong label Jul 7, 2016
@gnprice gnprice added this to the 0.5 milestone Jul 7, 2016
@ddfisher
Copy link
Collaborator

ddfisher commented Jul 8, 2016

Interestingly, this first of these errors isn't just a strict optional problem!

$ python3 -m mypy -c 'None == None'
<string>:1: error: Unsupported left operand type for == (None)

@ddfisher ddfisher changed the title None should be a subtype of object Operations on None should fall back to object Jul 8, 2016
@ddfisher
Copy link
Collaborator

ddfisher commented Jul 8, 2016

My renaming of this was incorrect -- currently None is a subtype of object, but object isn't in None's MRO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-strict-optional
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants