mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove `sphinx.util.parallel
` from the no-any-generics whitelist
This commit is contained in:
parent
2a411dcb53
commit
f071dc1b5b
@ -234,7 +234,6 @@ module = [
|
||||
"sphinx.domains",
|
||||
"sphinx.domains.c",
|
||||
"sphinx.domains.cpp",
|
||||
"sphinx.util.parallel",
|
||||
]
|
||||
disallow_any_generics = false
|
||||
|
||||
|
@ -35,12 +35,15 @@ class SerialTasks:
|
||||
pass
|
||||
|
||||
def add_task(
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None
|
||||
self,
|
||||
task_func: Callable[[Any], Any] | Callable[[], Any],
|
||||
arg: Any = None,
|
||||
result_func: Callable[[Any], Any] | None = None,
|
||||
) -> None:
|
||||
if arg is not None:
|
||||
res = task_func(arg)
|
||||
res = task_func(arg) # type: ignore[call-arg]
|
||||
else:
|
||||
res = task_func()
|
||||
res = task_func() # type: ignore[call-arg]
|
||||
if result_func:
|
||||
result_func(res)
|
||||
|
||||
@ -54,7 +57,7 @@ class ParallelTasks:
|
||||
def __init__(self, nproc: int) -> None:
|
||||
self.nproc = nproc
|
||||
# (optional) function performed by each task on the result of main task
|
||||
self._result_funcs: dict[int, Callable] = {}
|
||||
self._result_funcs: dict[int, Callable[[Any, Any], Any]] = {}
|
||||
# task arguments
|
||||
self._args: dict[int, list[Any] | None] = {}
|
||||
# list of subprocesses (both started and waiting)
|
||||
@ -68,14 +71,16 @@ class ParallelTasks:
|
||||
# task number of each subprocess
|
||||
self._taskid = 0
|
||||
|
||||
def _process(self, pipe: Any, func: Callable, arg: Any) -> None:
|
||||
def _process(
|
||||
self, pipe: Any, func: Callable[[Any], Any] | Callable[[], Any], arg: Any
|
||||
) -> None:
|
||||
try:
|
||||
collector = logging.LogCollector()
|
||||
with collector.collect():
|
||||
if arg is None:
|
||||
ret = func()
|
||||
ret = func() # type: ignore[call-arg]
|
||||
else:
|
||||
ret = func(arg)
|
||||
ret = func(arg) # type: ignore[call-arg]
|
||||
failed = False
|
||||
except BaseException as err:
|
||||
failed = True
|
||||
@ -85,7 +90,10 @@ class ParallelTasks:
|
||||
pipe.send((failed, collector.logs, ret))
|
||||
|
||||
def add_task(
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None
|
||||
self,
|
||||
task_func: Callable[[Any], Any] | Callable[[], Any],
|
||||
arg: Any = None,
|
||||
result_func: Callable[[Any, Any], Any] | None = None,
|
||||
) -> None:
|
||||
tid = self._taskid
|
||||
self._taskid += 1
|
||||
|
Loading…
Reference in New Issue
Block a user