Merge pull request #1 from Sengolda/typed-utils.py

Typed utils.py
This commit is contained in:
Sengolda 2021-10-28 01:25:14 +05:30 committed by GitHub
commit 93311d51d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,7 +170,7 @@ class CachedSlotProperty(Generic[T, T_co]):
class classproperty(Generic[T_co]):
def __init__(self, fget: Callable[[Any], T_co]) -> None:
self.fget = fget
self.fget: Callable[[Any], T_co] = fget
def __get__(self, instance: Optional[Any], owner: Type[Any]) -> T_co:
return self.fget(owner)
@ -207,7 +207,7 @@ class SequenceProxy(Generic[T_co], collections.abc.Sequence):
def __reversed__(self) -> Iterator[T_co]:
return reversed(self.__proxied)
def index(self, value: Any, *args, **kwargs) -> int:
def index(self, value: Any, *args: Any, **kwargs: Any) -> int:
return self.__proxied.index(value, *args, **kwargs)
def count(self, value: Any) -> int:
@ -507,7 +507,7 @@ def _parse_ratelimit_header(request: Any, *, use_clock: bool = False) -> float:
return float(reset_after)
async def maybe_coroutine(f, *args, **kwargs):
async def maybe_coroutine(f: Callable[..., Any], *args: Any, **kwargs: Any) -> Callable[..., Any]:
value = f(*args, **kwargs)
if _isawaitable(value):
return await value
@ -515,7 +515,7 @@ async def maybe_coroutine(f, *args, **kwargs):
return value
async def async_all(gen, *, check=_isawaitable):
async def async_all(gen, *, check=_isawaitable) -> bool:
for elem in gen:
if check(elem):
elem = await elem