After we add Optional checking, maybe we can make None more consistently mean "the type containing just the value None" instead of also "the uninhabited type" and "a value you can't use".
example.py:7: error: List item 0 has incompatible type None
example.py:8: error: Argument 1 to "append" of "list" has incompatible type None; expected None
example.py:10: error: List item 0 has incompatible type None
example.py:11: error: Argument 1 to "append" of "list" has incompatible type None; expected None
example.py:13: error: List item 0 has incompatible type None
example.py:14: error: Argument 1 to "append" of "list" has incompatible type None; expected None
example.py:25: error: Argument 1 to "Foo" has incompatible type None; expected None
example.py:26: error: Argument 1 to "append" of "Foo" has incompatible type None; expected None
So it seems that using None as a type still doesn't behave exactly as "the type containing just the value None" - more over, it seems like there's no way to trick mypy into declaring such a type.
Activity
ddfisher commented on Mar 7, 2016
After we add Optional checking, maybe we can make None more consistently mean "the type containing just the value None" instead of also "the uninhabited type" and "a value you can't use".
ddfisher commented on Jun 28, 2017
Fixed by #3024.
orenbenkiki commented on Dec 4, 2017
In mypy version 0.501, if you write:
Then mypy will complain:
So it seems that using None as a type still doesn't behave exactly as "the type containing just the value None" - more over, it seems like there's no way to trick mypy into declaring such a type.
JukkaL commented on Dec 4, 2017
@orenbenkiki 0.501 is pretty old. Have you a tried the latest versions? it works for me on git master.
orenbenkiki commented on Dec 4, 2017
Ah, it works in version 0.550. Thanks.
Version 0.501 was released in March this year, if that makes it "old.".. it is great to see mypy advancing so fast!
JukkaL commented on Dec 4, 2017
Yeah, 0.501 is already old in "mypy years" :-)