Closed
Description
This feels like a bug to me:
import functools
from typing import Optional, TextIO
def report(file: Optional[TextIO]) -> None:
print_ = functools.partial(print, file=file) if file is not None else print
print_("hello")
mypy reports
mypy_partial_print.py:7: error: "object" not callable
I would expect it to accept the code.
mypy version is 0.770. git master (commit 273a865) reports the same error.
Note that mypy accepts slight variations, e.g.
def report(file: TextIO) -> None:
print_ = functools.partial(print, file=file)
print_("hello")
is fine.
reveal_type(print_)
in the original example says it's a builtins.object
. It looks like mypy cannot reconcile a function with its own partial application.
Metadata
Metadata
Assignees
Labels
No labels