Skip to content
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

Spurious error on Callables returning None, under strict-optional #1957

Closed
gnprice opened this issue Jul 29, 2016 · 2 comments
Closed

Spurious error on Callables returning None, under strict-optional #1957

gnprice opened this issue Jul 29, 2016 · 2 comments
Assignees

Comments

@gnprice
Copy link
Collaborator

gnprice commented Jul 29, 2016

Under --strict-optional, something goes wrong in handling Callable types with return type None so that we don't allow them to be used even where the very same type is expected.

Short repro:

$ cat /tmp/foo.py
from typing import Callable

def f() -> None:
  ...

x = f  # type: Callable[[], None]

$ mypy /tmp/foo.py --strict-optional
/tmp/foo.py:6: error: Incompatible types in assignment (expression has type Callable[[], None], variable has type Callable[[], None])

This is perfectly well-typed code, and we shouldn't be giving an error. Running mypy --strict-optional on mypy itself, there are 16 error messages that appear to be caused by this issue.

The error message itself also has the problem that it's complaining of incompatible types and then printing precisely the same type description twice. This may indicate a second independent bug; that'll become clearer with a diagnosis of this one.

@gnprice
Copy link
Collaborator Author

gnprice commented Aug 1, 2016

This looks like it will probably be fixed by doing #1975. It'd be useful to debug a bit to confirm that.

@gnprice gnprice added this to the 0.4.x milestone Aug 4, 2016
@ddfisher
Copy link
Collaborator

ddfisher commented Aug 4, 2016

Fixed by #1980.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants