🐛 fix(anyio.py): change return type annotation of result() method from 'any' to 'Any' for better type hinting

🐛 fix(anyio.py): change parameter type annotation of get_task() method from 'int' to 'str' to match the actual type of task_id
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-05 15:33:31 -03:00
commit 779c021d78

View file

@ -17,7 +17,7 @@ class AnyIOTaskResult:
return self._status
@property
def result(self) -> any:
def result(self) -> Any:
return self._result
def ready(self) -> bool:
@ -41,10 +41,10 @@ class AnyIOBackend(TaskBackend):
) -> Tuple[str, AnyIOTaskResult]: # sourcery skip: remove-unnecessary-cast
async with anyio.create_task_group() as tg:
task_result = AnyIOTaskResult(tg)
await tg.spawn(task_result.run, task_func, *args, **kwargs)
tg.start_soon(task_result.run, task_func, *args, **kwargs)
task_id = str(id(task_result))
self.tasks[task_id] = task_result
return task_id, task_result
def get_task(self, task_id: int) -> AnyIOTaskResult:
def get_task(self, task_id: str) -> Any:
return self.tasks.get(task_id)