What is type annotation for "any callable but a class" in Python using Mypy?
Advertisements I’m trying to perfectly type annotate the following Python function: from typing import Callable, Any import inspect def foo(func: Callable[…, Any]) -> None: if inspect.isclass(func): raise ValueError # Do something… class Bad: pass def good() -> Bad: return Bad() foo(good) # OK foo(Bad) # NOK I would like to narrow down the Callable[…, Any]… Read More What is type annotation for "any callable but a class" in Python using Mypy?