diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3949f9..64c9181 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: hooks: - id: sort-all - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.4 + rev: v0.6.4 hooks: - id: ruff - id: ruff-format @@ -61,7 +61,7 @@ repos: args: [--wrap, "88"] files: (README\.md) - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell - repo: meta diff --git a/docs/source/conf.py b/docs/source/conf.py index c8d69ce..97a2cbb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -100,7 +100,7 @@ # Linkcode, based on numpy doc/source/conf.py -def linkcode_resolve(domain: str, info: dict[str, str]) -> str: # noqa: C901, PLR0912 +def linkcode_resolve(domain: str, info: dict[str, str]) -> str: # noqa: C901 """Determine the URL corresponding to Python object.""" if domain != "py": return None diff --git a/docs_src/custom_executors.py b/docs_src/custom_executors.py index 050461a..1d6ddba 100644 --- a/docs_src/custom_executors.py +++ b/docs_src/custom_executors.py @@ -1,6 +1,7 @@ from concurrent.futures import Executor from my_project.executor import CustomExecutor + from pytask_parallel import ParallelBackend from pytask_parallel import WorkerType from pytask_parallel import registry diff --git a/tests/conftest.py b/tests/conftest.py index 57004c3..4a6ce5f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -69,7 +69,7 @@ def invoke(self, *args, **kwargs): return super().invoke(*args, **kwargs) -@pytest.fixture() +@pytest.fixture def runner(): return CustomCliRunner() diff --git a/tests/test_backends.py b/tests/test_backends.py index 0c50da2..bc442fe 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -3,11 +3,12 @@ import pytest from pytask import ExitCode from pytask import cli + from pytask_parallel import ParallelBackend from pytask_parallel import registry -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_error_requesting_custom_backend_without_registration(runner, tmp_path): tmp_path.joinpath("task_example.py").write_text("def task_example(): pass") result = runner.invoke(cli, [tmp_path.as_posix(), "--parallel-backend", "custom"]) @@ -15,7 +16,7 @@ def test_error_requesting_custom_backend_without_registration(runner, tmp_path): assert "No registered parallel backend found" in result.output -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_error_while_instantiating_custom_backend(runner, tmp_path): hook_source = """ from pytask_parallel import ParallelBackend, registry @@ -34,7 +35,7 @@ def task_example(): pass assert "Could not instantiate parallel backend 'custom'." in result.output -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_register_custom_backend(runner, tmp_path): source = """ from loky import get_reusable_executor diff --git a/tests/test_capture.py b/tests/test_capture.py index 46dc5af..2ae605c 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -3,10 +3,11 @@ import pytest from pytask import ExitCode from pytask import cli + from pytask_parallel import ParallelBackend -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize( "parallel_backend", [ diff --git a/tests/test_config.py b/tests/test_config.py index 5918045..b51bf29 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -6,10 +6,11 @@ import pytest from pytask import ExitCode from pytask import build + from pytask_parallel import ParallelBackend -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize( ("pdb", "n_workers", "expected"), [ @@ -25,7 +26,7 @@ def test_interplay_between_debugging_and_parallel(tmp_path, pdb, n_workers, expe assert session.config["n_workers"] == expected -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize( ("configuration_option", "value", "exit_code"), [ diff --git a/tests/test_execute.py b/tests/test_execute.py index 31940f3..bb3d4d1 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -7,9 +7,9 @@ from pytask import ExitCode from pytask import build from pytask import cli + from pytask_parallel import ParallelBackend from pytask_parallel.execute import _Sleeper - from tests.conftest import restore_sys_path_and_module_after_test_execution _IMPLEMENTED_BACKENDS = [ @@ -25,7 +25,7 @@ ] -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_parallel_execution(tmp_path, parallel_backend): source = """ @@ -47,7 +47,7 @@ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")): assert tmp_path.joinpath("out_2.txt").exists() -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_parallel_execution_w_cli(runner, tmp_path, parallel_backend): source = """ @@ -77,7 +77,7 @@ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")): assert tmp_path.joinpath("out_2.txt").exists() -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_stop_execution_when_max_failures_is_reached(tmp_path, parallel_backend): source = """ @@ -105,7 +105,7 @@ def task_3(): time.sleep(3) assert len(session.execution_reports) == 2 -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_task_priorities(tmp_path, parallel_backend): source = """ @@ -146,7 +146,7 @@ def task_5(): assert last_task_name.endswith(("task_2", "task_5")) -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) @pytest.mark.parametrize("show_locals", [True, False]) def test_rendering_of_tracebacks_with_rich( @@ -172,7 +172,7 @@ def task_raising_error(): assert ("[0, 1, 2, 3, 4]" in result.output) is show_locals -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize( "parallel_backend", # Capturing warnings is not thread-safe. @@ -207,7 +207,7 @@ def task_example(produces): assert "task_example.py::task_example[1]" in warnings_block -@pytest.mark.unit() +@pytest.mark.unit def test_sleeper(): sleeper = _Sleeper(timings=[1, 2, 3], timing_idx=0) @@ -229,7 +229,7 @@ def test_sleeper(): assert 1 <= end - start <= 2 -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_task_that_return(runner, tmp_path, parallel_backend): source = """ @@ -249,7 +249,7 @@ def task_example() -> Annotated[str, Path("file.txt")]: ) -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_task_without_path_that_return(runner, tmp_path, parallel_backend): source = """ @@ -270,7 +270,7 @@ def test_task_without_path_that_return(runner, tmp_path, parallel_backend): ) -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("flag", ["--pdb", "--trace", "--dry-run"]) @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_backend): @@ -283,7 +283,7 @@ def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_back assert "Started 2 workers" not in result.output -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("code", ["breakpoint()", "import pdb; pdb.set_trace()"]) @pytest.mark.parametrize( "parallel_backend", @@ -298,7 +298,7 @@ def test_raise_error_on_breakpoint(runner, tmp_path, code, parallel_backend): assert "You cannot use 'breakpoint()'" in result.output -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_task_partialed(runner, tmp_path, parallel_backend): source = """ @@ -321,7 +321,7 @@ def create_text(text): assert tmp_path.joinpath("file.txt").exists() -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_execute_tasks_and_pass_values_by_python_node_return( runner, tmp_path, parallel_backend @@ -349,7 +349,7 @@ def task_create_file( assert tmp_path.joinpath("file.txt").read_text() == "This is the text." -@pytest.mark.end_to_end() +@pytest.mark.end_to_end @pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS) def test_execute_tasks_and_pass_values_by_python_node_product( runner, tmp_path, parallel_backend diff --git a/tests/test_jupyter/test_functional_interface.ipynb b/tests/test_jupyter/test_functional_interface.ipynb index 3750b24..95e34dc 100644 --- a/tests/test_jupyter/test_functional_interface.ipynb +++ b/tests/test_jupyter/test_functional_interface.ipynb @@ -9,10 +9,11 @@ "source": [ "from pathlib import Path\n", "\n", - "from typing_extensions import Annotated\n", - "\n", "import pytask\n", - "from pytask import ExitCode, PathNode, PythonNode" + "from pytask import ExitCode\n", + "from pytask import PathNode\n", + "from pytask import PythonNode\n", + "from typing_extensions import Annotated" ] }, { diff --git a/tests/test_jupyter/test_functional_interface_w_relative_path.ipynb b/tests/test_jupyter/test_functional_interface_w_relative_path.ipynb index 57303eb..d56a5b6 100644 --- a/tests/test_jupyter/test_functional_interface_w_relative_path.ipynb +++ b/tests/test_jupyter/test_functional_interface_w_relative_path.ipynb @@ -9,10 +9,11 @@ "source": [ "from pathlib import Path\n", "\n", - "from typing_extensions import Annotated\n", - "\n", "import pytask\n", - "from pytask import ExitCode, PathNode, PythonNode" + "from pytask import ExitCode\n", + "from pytask import PathNode\n", + "from pytask import PythonNode\n", + "from typing_extensions import Annotated" ] }, { diff --git a/tests/test_remote.py b/tests/test_remote.py index 366e30a..e123466 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -24,7 +24,7 @@ def custom_builder(n_workers): tmp_path.joinpath("config.py").write_text(textwrap.dedent(source)) -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_python_node(runner, tmp_path): source = """ from pathlib import Path @@ -65,7 +65,7 @@ def task_third( assert tmp_path.joinpath("output.txt").read_text() == "Hello World!" -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_local_path_as_input(runner, tmp_path): source = """ from pathlib import Path @@ -92,7 +92,7 @@ def task_example(path: Path = Path("in.txt")) -> Annotated[str, Path("output.txt assert tmp_path.joinpath("output.txt").read_text() == "Hello World!" -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_local_path_as_product(runner, tmp_path): source = """ from pytask import Product @@ -119,7 +119,7 @@ def task_example(path: Annotated[Path, Product] = Path("output.txt")): assert tmp_path.joinpath("output.txt").read_text() == "Hello World!" -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_local_path_as_return(runner, tmp_path): source = """ from pathlib import Path @@ -145,7 +145,7 @@ def task_example() -> Annotated[str, Path("output.txt")]: assert tmp_path.joinpath("output.txt").read_text() == "Hello World!" -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_pickle_node_with_local_path_as_input(runner, tmp_path): source = """ from pytask import PickleNode @@ -175,7 +175,7 @@ def task_example( assert tmp_path.joinpath("output.txt").read_text() == "Hello World!" -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_pickle_node_with_local_path_as_product(runner, tmp_path): source = """ from pytask import PickleNode, Product @@ -204,7 +204,7 @@ def task_example( assert pickle.loads(tmp_path.joinpath("data.pkl").read_bytes()) == "Hello World!" # noqa: S301 -@pytest.mark.end_to_end() +@pytest.mark.end_to_end def test_pickle_node_with_local_path_as_return(runner, tmp_path): source = """ from pytask import PickleNode