From 502654d8535ed4be4bd93f978232117dd5e210fd Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 29 Apr 2021 15:47:52 +0200 Subject: [PATCH] Fix mypy errors --- PFERD/crawler.py | 2 +- PFERD/utils.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PFERD/crawler.py b/PFERD/crawler.py index 36c528d..376cada 100644 --- a/PFERD/crawler.py +++ b/PFERD/crawler.py @@ -49,7 +49,7 @@ class Crawler(ABC): self._conductor.print(text) - def exclusive_output(self): + def exclusive_output(self) -> AsyncContextManager[None]: """ Acquire exclusive rights™ to the terminal output. While this context manager is held, output such as printing and progress bars from other diff --git a/PFERD/utils.py b/PFERD/utils.py index 3808f1d..08017aa 100644 --- a/PFERD/utils.py +++ b/PFERD/utils.py @@ -1,6 +1,6 @@ -import functools -import contextvars import asyncio +import contextvars +import functools import getpass from typing import Any, Callable, Optional, TypeVar @@ -13,14 +13,14 @@ async def to_thread(func: Callable[..., T], *args: Any, **kwargs: Any) -> T: loop = asyncio.get_event_loop() ctx = contextvars.copy_context() func_call = functools.partial(ctx.run, func, *args, **kwargs) - return await loop.run_in_executor(None, func_call) + return await loop.run_in_executor(None, func_call) # type: ignore -async def ainput(prompt: Optional[str] = None) -> str: +async def ainput(prompt: str) -> str: return await to_thread(lambda: input(prompt)) -async def agetpass(prompt: Optional[str] = None) -> str: +async def agetpass(prompt: str) -> str: return await to_thread(lambda: getpass.getpass(prompt))