🐛 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:
parent
8a47fb75cb
commit
779c021d78
1 changed files with 3 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ class AnyIOTaskResult:
|
||||||
return self._status
|
return self._status
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def result(self) -> any:
|
def result(self) -> Any:
|
||||||
return self._result
|
return self._result
|
||||||
|
|
||||||
def ready(self) -> bool:
|
def ready(self) -> bool:
|
||||||
|
|
@ -41,10 +41,10 @@ class AnyIOBackend(TaskBackend):
|
||||||
) -> Tuple[str, AnyIOTaskResult]: # sourcery skip: remove-unnecessary-cast
|
) -> Tuple[str, AnyIOTaskResult]: # sourcery skip: remove-unnecessary-cast
|
||||||
async with anyio.create_task_group() as tg:
|
async with anyio.create_task_group() as tg:
|
||||||
task_result = AnyIOTaskResult(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))
|
task_id = str(id(task_result))
|
||||||
self.tasks[task_id] = task_result
|
self.tasks[task_id] = task_result
|
||||||
return 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)
|
return self.tasks.get(task_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue