Skip to content

Commit 0ddd1c3

Browse files
committed
Fix typing, lint, and docs checks
1 parent 725634f commit 0ddd1c3

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ docs = [
3333
"matplotlib",
3434
"myst-parser",
3535
"nbsphinx",
36-
"sphinx",
36+
"sphinx<9",
3737
"sphinx-autobuild",
3838
"sphinx-click",
3939
"sphinx-copybutton",

src/pytask_parallel/backends.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"set_worker_root",
3030
]
3131

32-
_WORKER_ROOT: str | None = None
32+
_WORKER_STATE: dict[str, str | None] = {"root": None}
3333

3434

3535
def set_worker_root(path: os.PathLike[str] | str) -> None:
@@ -40,9 +40,8 @@ def set_worker_root(path: os.PathLike[str] | str) -> None:
4040
task modules are importable by reference, which avoids pickling module globals.
4141
4242
"""
43-
global _WORKER_ROOT
4443
root = os.fspath(path)
45-
_WORKER_ROOT = root
44+
_WORKER_STATE["root"] = root
4645
if root not in sys.path:
4746
sys.path.insert(0, root)
4847
# Ensure custom process backends can import task modules by reference.
@@ -117,14 +116,18 @@ def _get_dask_executor(n_workers: int) -> Executor:
117116
def _get_loky_executor(n_workers: int) -> Executor:
118117
"""Get a loky executor."""
119118
return get_reusable_executor(
120-
max_workers=n_workers, initializer=_configure_worker, initargs=(_WORKER_ROOT,)
119+
max_workers=n_workers,
120+
initializer=_configure_worker,
121+
initargs=(_WORKER_STATE["root"],),
121122
)
122123

123124

124125
def _get_process_pool_executor(n_workers: int) -> Executor:
125126
"""Get a process pool executor."""
126127
return _CloudpickleProcessPoolExecutor(
127-
max_workers=n_workers, initializer=_configure_worker, initargs=(_WORKER_ROOT,)
128+
max_workers=n_workers,
129+
initializer=_configure_worker,
130+
initargs=(_WORKER_STATE["root"],),
128131
)
129132

130133

src/pytask_parallel/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _render_traceback_to_string(
217217
traceback = Traceback(exc_info, show_locals=show_locals)
218218
segments = console.render(cast("Any", traceback), options=console_options)
219219
text = "".join(segment.text for segment in segments)
220-
return (*exc_info[:2], text) # ty: ignore[invalid-return-type]
220+
return (*exc_info[:2], text)
221221

222222

223223
def _handle_function_products(

0 commit comments

Comments
 (0)