Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=25']
Expand Down Expand Up @@ -31,24 +31,15 @@ repos:
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.6
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/dosisod/refurb
rev: v1.21.0
rev: v1.24.0
hooks:
- id: refurb
args: [--ignore, FURB126]
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args: [-v, --fail-under=40, src, tests]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand All @@ -63,7 +54,7 @@ repos:
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.5.1'
rev: 'v1.7.1'
hooks:
- id: mypy
args: [
Expand All @@ -85,7 +76,7 @@ repos:
hooks:
- id: check-manifest
args: [--no-build-isolation]
additional_dependencies: [setuptools-scm, toml]
additional_dependencies: [setuptools-scm, toml, wheel]
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
26 changes: 4 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,20 @@ target-version = "py38"
select = ["ALL"]
fix = true
extend-ignore = [
"I", # ignore isort
"TRY", # ignore tryceratops.
"TCH", # ignore non-guarded type imports.
# Numpy docstyle
"D107",
"D203",
"D212",
"D213",
"D402",
"D413",
"D415",
"D416",
"D417",
# Others.
"D404", # Do not start module docstring with "This".
"RET504", # unnecessary variable assignment before return.
"S101", # raise errors for asserts.
"B905", # strict parameter for zip that was implemented in py310.
"I", # ignore isort
"ANN101", # type annotating self
"ANN102", # type annotating cls
"FBT", # flake8-boolean-trap
"EM", # flake8-errmsg
"ANN401", # flake8-annotate typing.Any
"PD", # pandas-vet
"COM812", # trailing comma missing, but black takes care of that
"D401", # imperative mood for first line. too many false-positives.
"SLF001", # access private members.
"COM812", # Comply with ruff-format.
"ISC001", # Comply with ruff-format.
]


[tool.ruff.per-file-ignores]
"tests/*" = ["D", "ANN", "PLR2004"]
"tests/*" = ["D", "ANN", "PLR2004", "S101"]


[tool.ruff.pydocstyle]
Expand Down
2 changes: 1 addition & 1 deletion src/pytask_parallel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module is the main namespace of the package."""
"""Contains the main namespace of the package."""
from __future__ import annotations

try:
Expand Down
7 changes: 5 additions & 2 deletions src/pytask_parallel/backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module configures the available backends."""
"""Configures the available backends."""
from __future__ import annotations

import enum
Expand All @@ -23,7 +23,10 @@ class CloudpickleProcessPoolExecutor(ProcessPoolExecutor):

# The type signature is wrong for version above Py3.7. Fix when 3.7 is deprecated.
def submit( # type: ignore[override]
self, fn: Callable[..., Any], *args: Any, **kwargs: Any # noqa: ARG002
self,
fn: Callable[..., Any],
*args: Any, # noqa: ARG002
**kwargs: Any,
) -> Future[Any]:
"""Submit a new task."""
return super().submit(
Expand Down
5 changes: 3 additions & 2 deletions src/pytask_parallel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def pytask_parse_config(config: dict[str, Any]) -> None:

if (
isinstance(config["parallel_backend"], str)
and config["parallel_backend"] in ParallelBackend._value2member_map_
and config["parallel_backend"] in ParallelBackend._value2member_map_ # noqa: SLF001
):
config["parallel_backend"] = ParallelBackend(config["parallel_backend"])
elif (
Expand All @@ -26,7 +26,8 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
):
pass
else:
raise ValueError("Invalid value for 'parallel_backend'.")
msg = f"Invalid value for 'parallel_backend'. Got {config['parallel_backend']}."
raise ValueError(msg)

config["delay"] = 0.1

Expand Down
11 changes: 6 additions & 5 deletions src/pytask_parallel/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[Any] | None:


def _raise_exception_on_breakpoint(*args: Any, **kwargs: Any) -> None: # noqa: ARG001
raise RuntimeError(
msg = (
"You cannot use 'breakpoint()' or 'pdb.set_trace()' while parallelizing the "
"execution of tasks with pytask-parallel. Please, remove the breakpoint or run "
"the task without parallelization to debug it."
)
raise RuntimeError(msg)


def _patch_set_trace_and_breakpoint() -> None:
Expand All @@ -235,7 +236,7 @@ def _patch_set_trace_and_breakpoint() -> None:
def _execute_task( # noqa: PLR0913
task: PTask,
kwargs: dict[str, Any],
show_locals: bool,
show_locals: bool, # noqa: FBT001
console_options: ConsoleOptions,
session_filterwarnings: tuple[str, ...],
task_filterwarnings: tuple[Mark, ...],
Expand All @@ -251,7 +252,7 @@ def _execute_task( # noqa: PLR0913

with warnings.catch_warnings(record=True) as log:
# mypy can't infer that record=True means log is not None; help it.
assert log is not None
assert log is not None # noqa: S101

for arg in session_filterwarnings:
warnings.filterwarnings(*parse_warning_filter(arg, escape=False))
Expand Down Expand Up @@ -284,7 +285,7 @@ def _execute_task( # noqa: PLR0913
nodes = tree_leaves(task.produces["return"])
values = structure_return.flatten_up_to(out)
for node, value in zip(nodes, values):
node.save(value) # type: ignore[attr-defined]
node.save(value)

processed_exc_info = None

Expand All @@ -305,7 +306,7 @@ def _execute_task( # noqa: PLR0913

def _process_exception(
exc_info: tuple[type[BaseException], BaseException, TracebackType | None],
show_locals: bool,
show_locals: bool, # noqa: FBT001
console_options: ConsoleOptions,
) -> tuple[type[BaseException], BaseException, str]:
"""Process the exception and convert the traceback to a string."""
Expand Down