You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should be fixable in typeshed once we have support for PEP 647 (https://www.python.org/dev/peps/pep-0647/). Mypy could also special-case these functions directly but that might be overkill.
@JelleZijlstra thanks for considering the issue. In fact, I think that mypy should handle inspect.is* methods directly as this seems a canonical way to check whether an object is a callable, a coroutine etc. at runtime.
Otherwise, it would be great if mypy documentation explicitly stated how the user is expected to check for "is a callable" property. (There is no isinstance(obj, Callable) as far as I am aware.)
Activity
mristin commentedon Feb 19, 2021
(I am not sure if this is a bug or a feature request, please change as you see fit.)
JelleZijlstra commentedon Feb 19, 2021
This should be fixable in typeshed once we have support for PEP 647 (https://www.python.org/dev/peps/pep-0647/). Mypy could also special-case these functions directly but that might be overkill.
mristin commentedon Feb 20, 2021
@JelleZijlstra thanks for considering the issue. In fact, I think that mypy should handle
inspect.is*methods directly as this seems a canonical way to check whether an object is a callable, a coroutine etc. at runtime.Otherwise, it would be great if mypy documentation explicitly stated how the user is expected to check for "is a callable" property. (There is no
isinstance(obj, Callable)as far as I am aware.)Edit: typo
JelleZijlstra commentedon Feb 20, 2021
We support using
callable()(as of #2627).AlexWaygood commentedon Apr 1, 2022
Hmm, well,
TypeGuardis now supported and the relevant changes to typeshed have been made, but there still seem to be some problems on mypy's end:erictraut commentedon Aug 17, 2023
It looks like this is working as expected with the latest version of mypy.
The first revealed type is now: