Summary
https://play.ty.dev/c4b6196b-5a1c-4f2e-a61c-09b50d38fbc0
from typing import Any, reveal_type
from collections.abc import Callable
class Test:
func: Callable[..., Any]
foo = Test()
first = getattr(foo, "func", None)
if callable(first):
reveal_type(first)
if callable(second:=getattr(foo, "func", None)):
reveal_type(second)
Revealed type: `Any & Top[(...) -> object]` (revealed-type) [Ln 10, Col 17]
Revealed type: `Any | None` (revealed-type) [Ln 12, Col 17]
Even if the ty can't fully infer the type of func, it should still be able to determine whether it is a callable object or not.
If this problem is caused by #626, please close it as a duplicate.
Version
playground 26230b1ed