-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
astral-sh/ruff
#22369Labels
Milestone
Description
Summary
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
Reactions are currently unavailable