mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Adjust types for asyncio.coroutines functions (#5517)
Noticed this in mypy-primer output in #5516 on this code: https://github.com/encode/starlette/blob/master/starlette/testclient.py#L74 It calls `iscoroutinefunction()` on an object that may be None, which got flagged as an error but is actually fine; it just returns False. We could also potentially use TypeGuard here, especially for `iscoroutine` which is just an `isinstance` call.
This commit is contained in:
@@ -3,5 +3,5 @@ from typing import Any, Callable, TypeVar
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def coroutine(func: _F) -> _F: ...
|
||||
def iscoroutinefunction(func: Callable[..., Any]) -> bool: ...
|
||||
def iscoroutine(obj: Any) -> bool: ...
|
||||
def iscoroutinefunction(func: object) -> bool: ...
|
||||
def iscoroutine(obj: object) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user