diff --git a/mypy/test/data/check-functions.test b/mypy/test/data/check-functions.test index b4facd8c1d14..6358edce2644 100644 --- a/mypy/test/data/check-functions.test +++ b/mypy/test/data/check-functions.test @@ -1531,6 +1531,11 @@ from typing import Callable, Any def foo(f: Callable) -> bool: return f() + +def f1() -> bool: + return False + +foo(f1) [builtins fixtures/bool.py] [case testFunctionNestedWithinWith] diff --git a/mypy/typeanal.py b/mypy/typeanal.py index 345adbba8013..0ee10da7bd92 100644 --- a/mypy/typeanal.py +++ b/mypy/typeanal.py @@ -210,12 +210,13 @@ def visit_ellipsis_type(self, t: EllipsisType) -> Type: def analyze_callable_type(self, t: UnboundType) -> Type: fallback = self.builtin_type('builtins.function') if len(t.args) == 0: - # Callable (bare) + # Callable (bare). Treat as Callable[..., Any]. return CallableType([AnyType(), AnyType()], [nodes.ARG_STAR, nodes.ARG_STAR2], [None, None], ret_type=AnyType(), - fallback=fallback) + fallback=fallback, + is_ellipsis_args=True) elif len(t.args) == 2: ret_type = t.args[1].accept(self) if isinstance(t.args[0], TypeList):