-
Notifications
You must be signed in to change notification settings - Fork 199
Open
Labels
needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.An issue where it's not clear whether there is a bug or we are behaving as expected.scoping-control-flowissues related to scoping and control flowissues related to scoping and control flowtypechecking
Description
Describe the Bug
In python there are roughly 5 distinct but from a typing POV equivalent ways to check whether something is callable:
builtins.callable(x)isinstance(x, collections.abc.Callable)isinstance(x, AnyCallable)(Protocol withdef __call__(self, *args: Any, **kwargs: Any) -> Any)case collections.abc.Callable()case AnyCallable()
Consequently, these should give equivalent narrowing, but they do not. pyrefly also currently lacks support for ② (#1604)
The attached sandbox contains a full test suite. For each test class, all test cases should yield identical reveal_type results, but they currently do not.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Metadata
Metadata
Assignees
Labels
needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.An issue where it's not clear whether there is a bug or we are behaving as expected.scoping-control-flowissues related to scoping and control flowissues related to scoping and control flowtypechecking