From 72952c93db1c975b41299b96c4a8374f3f3e7c3b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Dec 2022 19:57:09 +0000 Subject: [PATCH 1/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/docformatter: v1.5.0 → v1.5.1](https://github.com/PyCQA/docformatter/compare/v1.5.0...v1.5.1) - [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8202858..80c139e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: hooks: - id: setup-cfg-fmt - repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 + rev: v1.5.1 hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] @@ -54,7 +54,7 @@ repos: - id: blacken-docs additional_dependencies: [black] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 types: [python] From d08bd6691bfb6c32a8fce3bbf2c1d6e0d5e3075b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 9 Jan 2023 18:46:50 +0100 Subject: [PATCH 2/5] Add hooks. --- .pre-commit-config.yaml | 43 +++++++++++++++++--------------- CHANGES.md | 1 + pyproject.toml | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80c139e..6bc8942 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,27 +53,15 @@ repos: hooks: - id: blacken-docs additional_dependencies: [black] -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.215 hooks: - - id: flake8 - types: [python] - additional_dependencies: [ - flake8-alfred, - flake8-bugbear, - flake8-builtins, - flake8-comprehensions, - flake8-docstrings, - flake8-eradicate, - flake8-print, - flake8-pytest-style, - flake8-todo, - flake8-typing-imports, - flake8-unused-arguments, - pep8-naming, - pydocstyle, - Pygments, - ] + - id: ruff +- repo: https://github.com/dosisod/refurb + rev: v1.9.1 + hooks: + - id: refurb + args: [--ignore, FURB126] - repo: https://github.com/econchick/interrogate rev: 1.5.0 hooks: @@ -93,6 +81,21 @@ repos: hooks: - id: codespell args: [-L als, -L falsy] +- repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v0.991' + hooks: + - id: mypy + args: [ + --no-strict-optional, + --ignore-missing-imports, + ] + additional_dependencies: [ + attrs>=21.3.0, + click, + types-PyYAML, + types-setuptools + ] + pass_filenames: false - repo: https://github.com/mgedmin/check-manifest rev: "0.49" hooks: diff --git a/CHANGES.md b/CHANGES.md index d003de2..c87f960 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ releases are available on [Anaconda.org](https://anaconda.org/conda-forge/pytask - {pull}`49` removes support for INI configurations. - {pull}`50` removes the deprecation message and related code to the old API. +- {pull}`51` adds mypy, ruff, and refurb. ## 0.2.1 - 2022-04-19 diff --git a/pyproject.toml b/pyproject.toml index b2714c9..91df5d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,3 +5,58 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "src/pytask_latex/_version.py" + + +[tool.mypy] +files = ["src", "tests"] +check_untyped_defs = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true + + +[[tool.mypy.overrides]] +module = "tests.*" +disallow_untyped_defs = false +ignore_errors = true + + +[tool.ruff] +target-version = "py37" +select = ["ALL"] +fix = true +extend-ignore = [ + # 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 +] + + +[tool.ruff.per-file-ignores] +"tests/*" = ["D", "ANN"] + + +[tool.ruff.pydocstyle] +convention = "numpy" From f09ae45dd8b5161d6a26b07f3e5b5fae5b4401e2 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 9 Jan 2023 19:29:50 +0100 Subject: [PATCH 3/5] Fix errors. --- src/pytask_latex/__init__.py | 1 + src/pytask_latex/collect.py | 76 +++++++++---------------- src/pytask_latex/compilation_steps.py | 11 +++- src/pytask_latex/execute.py | 14 ++--- src/pytask_latex/parametrize.py | 9 +-- src/pytask_latex/plugin.py | 3 +- src/pytask_latex/py.typed | 0 src/pytask_latex/utils.py | 4 +- tests/__init__.py | 0 tests/test_collect.py | 4 +- tests/test_config.py | 2 +- tests/test_execute.py | 40 ++++++------- tests/test_latex_dependency_scanner.py | 2 +- tests/test_normal_execution_w_plugin.py | 6 +- tests/test_parallel.py | 16 +++--- tests/test_parametrize.py | 16 +++--- 16 files changed, 98 insertions(+), 106 deletions(-) create mode 100644 src/pytask_latex/py.typed create mode 100644 tests/__init__.py diff --git a/src/pytask_latex/__init__.py b/src/pytask_latex/__init__.py index dcc8e73..2a4567b 100644 --- a/src/pytask_latex/__init__.py +++ b/src/pytask_latex/__init__.py @@ -1,3 +1,4 @@ +"""This module contains the main namespace.""" from __future__ import annotations try: diff --git a/src/pytask_latex/collect.py b/src/pytask_latex/collect.py index dead405..be2d52f 100644 --- a/src/pytask_latex/collect.py +++ b/src/pytask_latex/collect.py @@ -27,52 +27,19 @@ from pytask_latex.utils import to_list -_ERROR_MSG = """The old syntax for @pytask.mark.latex was suddenly deprecated starting \ -with pytask-latex v0.2 to provide a better user experience. Thank you for your \ -understanding! - -It is recommended to upgrade to the new syntax, so you enjoy all the benefits of v0.2 of -pytask and a better interface for pytask-latex. - -You can find a manual here: \ -https://github.com/pytask-dev/pytask-latex/blob/v0.2.0/README.md - -Upgrading can be as easy as rewriting your current task from - - @pytask.mark.latex("--some-option") - @pytask.mark.depends_on({"source": "script.tex") - @pytask.mark.produces("document.pdf") - def task_latex(): - ... - -to - - from pytask_latex import compilation_steps as cs - - - @pytask.mark.latex( - script="script.tex", - document="document.pdf", - compilation_steps=cs.latexmk(options="--some-options"), - ) - def task_latex(): - ... - -You can also fix the version of pytask and pytask-latex to <0.2, so you do not have to \ -to upgrade. At the same time, you will not enjoy the improvements released with \ -version v0.2 of pytask and pytask-latex. - -""" - - def latex( *, script: str | Path, document: str | Path, compilation_steps: str | Callable[..., Any] - | Sequence[str | Callable[..., Any]] = None, -) -> tuple[str | Path | None, list[Callable[..., Any]]]: + | Sequence[str | Callable[..., Any]] + | None = None, +) -> tuple[ + str | Path, + str | Path, + str | Callable[..., Any] | Sequence[str | Callable[..., Any]] | None, +]: """Specify command line options for latexmk. Parameters @@ -88,8 +55,16 @@ def latex( return script, document, compilation_steps -def compile_latex_document(compilation_steps, path_to_tex, path_to_document): - """Replaces the dummy function provided by the user.""" +def compile_latex_document( + compilation_steps: list[Callable[..., Any]], + path_to_tex: Path, + path_to_document: Path, +) -> None: + """Compile a LaTeX document iterating over compilations steps. + + Replaces the placeholder function provided by the user. + + """ for step in compilation_steps: try: step(path_to_tex=path_to_tex, path_to_document=path_to_document) @@ -98,7 +73,9 @@ def compile_latex_document(compilation_steps, path_to_tex, path_to_document): @hookimpl -def pytask_collect_task(session, path, name, obj): +def pytask_collect_task( + session: Session, path: Path, name: str, obj: Any +) -> Task | None: """Perform some checks.""" __tracebackhide__ = True @@ -130,7 +107,7 @@ def pytask_collect_task(session, path, name, obj): task = Task( base_name=name, path=path, - function=_copy_func(compile_latex_document), + function=_copy_func(compile_latex_document), # type: ignore[arg-type] depends_on=dependencies, produces=products, markers=markers, @@ -154,7 +131,7 @@ def pytask_collect_task(session, path, name, obj): if not ( isinstance(document_node, FilePathNode) - and document_node.value.suffix in [".pdf", ".ps", ".dvi"] + and document_node.value.suffix in (".pdf", ".ps", ".dvi") ): raise ValueError( "The 'document' keyword of the @pytask.mark.latex decorator must point " @@ -181,9 +158,10 @@ def pytask_collect_task(session, path, name, obj): task = _add_latex_dependencies_retroactively(task, session) return task + return None -def _add_latex_dependencies_retroactively(task, session): +def _add_latex_dependencies_retroactively(task: Task, session: Session) -> Task: """Add dependencies from LaTeX document to task. Unfortunately, the dependencies have to be added retroactively, after the task has @@ -291,7 +269,9 @@ def _collect_node( return collected_node -def _parse_compilation_steps(compilation_steps): +def _parse_compilation_steps( + compilation_steps: str | Callable[..., Any] | Sequence[str | Callable[..., Any]] +) -> list[Callable[..., Any]]: """Parse compilation steps.""" __tracebackhide__ = True @@ -303,7 +283,7 @@ def _parse_compilation_steps(compilation_steps): try: parsed_step = getattr(cs, step) except AttributeError: - raise ValueError(f"Compilation step {step!r} is unknown.") + raise ValueError(f"Compilation step {step!r} is unknown.") from None parsed_compilation_steps.append(parsed_step()) elif callable(step): parsed_compilation_steps.append(step) diff --git a/src/pytask_latex/compilation_steps.py b/src/pytask_latex/compilation_steps.py index ac7ba9a..b6595d1 100644 --- a/src/pytask_latex/compilation_steps.py +++ b/src/pytask_latex/compilation_steps.py @@ -13,16 +13,23 @@ def compilation_step(path_to_tex: Path, path_to_document: Path): from __future__ import annotations import subprocess +from pathlib import Path +from typing import Any +from typing import Callable from pytask_latex.path import relative_to from pytask_latex.utils import to_list -def latexmk(options=("--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd")): +def latexmk( + options: str + | list[str] + | tuple[str, ...] = ("--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd") +) -> Callable[..., Any]: """Compilation step that calls latexmk.""" options = [str(i) for i in to_list(options)] - def run_latexmk(path_to_tex, path_to_document): + def run_latexmk(path_to_tex: Path, path_to_document: Path) -> None: job_name_opt = [f"--jobname={path_to_document.stem}"] out_dir_opt = [ f"--output-directory={relative_to(path_to_tex, path_to_document.parent)}" diff --git a/src/pytask_latex/execute.py b/src/pytask_latex/execute.py index e378532..7603bb1 100644 --- a/src/pytask_latex/execute.py +++ b/src/pytask_latex/execute.py @@ -5,14 +5,14 @@ from pytask import has_mark from pytask import hookimpl +from pytask import Task @hookimpl -def pytask_execute_task_setup(task): +def pytask_execute_task_setup(task: Task) -> None: """Check that latexmk is found on the PATH if a LaTeX task should be executed.""" - if has_mark(task, "latex"): - if shutil.which("latexmk") is None: - raise RuntimeError( - "latexmk is needed to compile LaTeX documents, but it is not found on " - "your PATH." - ) + if has_mark(task, "latex") and shutil.which("latexmk") is None: + raise RuntimeError( + "latexmk is needed to compile LaTeX documents, but it is not found on " + "your PATH." + ) diff --git a/src/pytask_latex/parametrize.py b/src/pytask_latex/parametrize.py index 5041761..6bd5266 100644 --- a/src/pytask_latex/parametrize.py +++ b/src/pytask_latex/parametrize.py @@ -1,13 +1,14 @@ """Parametrize tasks.""" from __future__ import annotations +from typing import Any + import pytask from pytask import hookimpl @hookimpl -def pytask_parametrize_kwarg_to_marker(obj, kwargs): +def pytask_parametrize_kwarg_to_marker(obj: Any, kwargs: dict[str, Any]) -> None: """Register kwargs as latex marker.""" - if callable(obj): - if "latex" in kwargs: - pytask.mark.latex(**kwargs.pop("latex"))(obj) + if callable(obj) and "latex" in kwargs: + pytask.mark.latex(**kwargs.pop("latex"))(obj) diff --git a/src/pytask_latex/plugin.py b/src/pytask_latex/plugin.py index ca67c7a..52adddf 100644 --- a/src/pytask_latex/plugin.py +++ b/src/pytask_latex/plugin.py @@ -1,6 +1,7 @@ """Entry-point for the plugin.""" from __future__ import annotations +from pluggy import PluginManager from pytask import hookimpl from pytask_latex import collect from pytask_latex import config @@ -9,7 +10,7 @@ @hookimpl -def pytask_add_hooks(pm): +def pytask_add_hooks(pm: PluginManager) -> None: """Register some plugins.""" pm.register(collect) pm.register(config) diff --git a/src/pytask_latex/py.typed b/src/pytask_latex/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/pytask_latex/utils.py b/src/pytask_latex/utils.py index 7de13e8..535ff76 100644 --- a/src/pytask_latex/utils.py +++ b/src/pytask_latex/utils.py @@ -1,9 +1,11 @@ +"""This module contains shared functions.""" from __future__ import annotations +from typing import Any from typing import Sequence -def to_list(scalar_or_iter): +def to_list(scalar_or_iter: Any) -> list[Any]: """Convert scalars and iterables to list. Parameters diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_collect.py b/tests/test_collect.py index e5e26fa..536f2ba 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -6,9 +6,9 @@ from pytask_latex.collect import latex -@pytest.mark.unit +@pytest.mark.unit() @pytest.mark.parametrize( - "kwargs, expectation, expected", + ("kwargs", "expectation", "expected"), [ ({}, pytest.raises(TypeError, match=r"latex\(\) missing 2 required"), None), ( diff --git a/tests/test_config.py b/tests/test_config.py index 8dc4f93..d7b2ea9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,7 +4,7 @@ from pytask import main -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_marker_is_configured(tmp_path): session = main({"paths": tmp_path}) assert "latex" in session.config["markers"] diff --git a/tests/test_execute.py b/tests/test_execute.py index 3c89f26..ce893bc 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -15,12 +15,12 @@ from pytask_latex.execute import pytask_execute_task_setup -@pytest.mark.unit +@pytest.mark.unit() def test_pytask_execute_task_setup(monkeypatch): """Make sure that the task setup raises errors.""" # Act like latexmk is installed since we do not test this. monkeypatch.setattr( - "pytask_latex.execute.shutil.which", lambda x: None # noqa: U100 + "pytask_latex.execute.shutil.which", lambda x: None # noqa: ARG005 ) task = Task( base_name="example", path=Path(), function=None, markers=[Mark("latex", (), {})] @@ -31,7 +31,7 @@ def test_pytask_execute_task_setup(monkeypatch): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document(runner, tmp_path): """Test simple compilation.""" task_source = """ @@ -57,7 +57,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_w_relative(runner, tmp_path): """Test simple compilation.""" task_source = f""" @@ -89,7 +89,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_to_different_name(runner, tmp_path): """Compile a LaTeX document where source and output name differ.""" task_source = """ @@ -116,7 +116,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_w_bibliography(runner, tmp_path): """Compile a LaTeX document with bibliography.""" task_source = """ @@ -156,7 +156,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_raise_error_if_latexmk_is_not_found(tmp_path, monkeypatch): task_source = """ import pytask @@ -178,7 +178,7 @@ def task_compile_document(): # Hide latexmk if available. monkeypatch.setattr( - "pytask_latex.execute.shutil.which", lambda x: None # noqa: U100 + "pytask_latex.execute.shutil.which", lambda x: None # noqa: ARG005 ) session = main({"paths": tmp_path}) @@ -189,7 +189,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_w_xelatex(runner, tmp_path): task_source = """ import pytask @@ -224,7 +224,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_w_two_dependencies(runner, tmp_path): task_source = """ import pytask @@ -252,7 +252,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_fail_because_script_is_not_latex(tmp_path): task_source = """ import pytask @@ -280,7 +280,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_document_to_out_if_document_has_relative_resources(tmp_path): """Test that motivates the ``"--cd"`` flag. @@ -323,7 +323,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_document_w_wrong_flag(tmp_path): """Test that wrong flags raise errors.""" tmp_path.joinpath("sub").mkdir(parents=True) @@ -358,7 +358,7 @@ def task_compile_document(): @needs_latexmk -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_document_w_image(runner, tmp_path): task_source = f""" import pytask @@ -392,7 +392,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_w_multiple_marks(runner, tmp_path): """Test simple compilation.""" task_source = """ @@ -420,7 +420,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_with_wrong_extension(runner, tmp_path): """Test simple compilation.""" task_source = """ @@ -447,7 +447,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_w_bibliography_and_keep_bbl(runner, tmp_path): """Compile a LaTeX document with bibliography.""" task_source = """ @@ -491,9 +491,9 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() @pytest.mark.parametrize( - "step, message", + ("step", "message"), [ ("'unknown'", "Compilation step 'unknown' is unknown."), (1, "Compilation step 1 is not a valid step."), @@ -531,7 +531,7 @@ def task_compile_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_compile_latex_document_with_task_decorator(runner, tmp_path): """Test simple compilation.""" task_source = """ diff --git a/tests/test_latex_dependency_scanner.py b/tests/test_latex_dependency_scanner.py index 7c8783a..6a14990 100644 --- a/tests/test_latex_dependency_scanner.py +++ b/tests/test_latex_dependency_scanner.py @@ -11,7 +11,7 @@ @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() @pytest.mark.parametrize("infer_dependencies", ["true", "false"]) def test_infer_dependencies_from_task(tmp_path, infer_dependencies): task_source = """ diff --git a/tests/test_normal_execution_w_plugin.py b/tests/test_normal_execution_w_plugin.py index 4a810eb..78d67cc 100644 --- a/tests/test_normal_execution_w_plugin.py +++ b/tests/test_normal_execution_w_plugin.py @@ -8,12 +8,12 @@ from pytask import ExitCode -@pytest.mark.end_to_end +@pytest.mark.end_to_end() @pytest.mark.parametrize( "dependencies", - [[], ["in.txt"], ["in_1.txt", "in_2.txt"]], + [(), ("in.txt",), ("in_1.txt", "in_2.txt")], ) -@pytest.mark.parametrize("products", [["out.txt"], ["out_1.txt", "out_2.txt"]]) +@pytest.mark.parametrize("products", [("out.txt",), ("out_1.txt", "out_2.txt")]) def test_execution_w_varying_dependencies_products( runner, tmp_path, dependencies, products ): diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 3162d53..92bab10 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -32,7 +32,7 @@ @xfail_on_remote @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parallel_parametrization_over_source_files_w_parametrize(runner, tmp_path): source = """ import pytask @@ -71,7 +71,7 @@ def task_compile_latex_document(): assert result.exit_code == ExitCode.OK duration_normal = time.time() - start - for name in ["document_1.pdf", "document_2.pdf"]: + for name in ("document_1.pdf", "document_2.pdf"): tmp_path.joinpath(name).unlink() start = time.time() @@ -86,7 +86,7 @@ def task_compile_latex_document(): @xfail_on_remote @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parallel_parametrization_over_source_files_w_loop(runner, tmp_path): source = """ import pytask @@ -122,7 +122,7 @@ def task_compile_latex_document(): assert result.exit_code == ExitCode.OK duration_normal = time.time() - start - for name in ["document_1.pdf", "document_2.pdf"]: + for name in ("document_1.pdf", "document_2.pdf"): tmp_path.joinpath(name).unlink() start = time.time() @@ -137,7 +137,7 @@ def task_compile_latex_document(): @xfail_on_remote @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parallel_parametrization_over_source_file_w_parametrize(runner, tmp_path): source = """ import pytask @@ -181,7 +181,7 @@ def task_compile_latex_document(): assert result.exit_code == ExitCode.OK duration_normal = time.time() - start - for name in ["document.pdf", "document.dvi"]: + for name in ("document.pdf", "document.dvi"): tmp_path.joinpath(name).unlink() start = time.time() @@ -196,7 +196,7 @@ def task_compile_latex_document(): @xfail_on_remote @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parallel_parametrization_over_source_file_w_loop(runner, tmp_path): source = """ import pytask @@ -231,7 +231,7 @@ def task_compile_latex_document(): assert result.exit_code == ExitCode.OK duration_normal = time.time() - start - for name in ["document.pdf", "document.dvi"]: + for name in ("document.pdf", "document.dvi"): tmp_path.joinpath(name).unlink() start = time.time() diff --git a/tests/test_parametrize.py b/tests/test_parametrize.py index 6209986..6096bad 100644 --- a/tests/test_parametrize.py +++ b/tests/test_parametrize.py @@ -11,7 +11,7 @@ @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parametrized_compilation_of_latex_documents_w_parametrize(tmp_path): task_source = """ import pytask @@ -25,10 +25,10 @@ def task_compile_latex_document(): """ tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(task_source)) - for name, content in [ + for name, content in ( ("document_1.tex", "Like a worn out recording"), ("document_2.tex", "Of a favorite song"), - ]: + ): latex_source = rf""" \documentclass{{report}} \begin{{document}} @@ -46,7 +46,7 @@ def task_compile_latex_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parametrized_compilation_of_latex_documents_w_loop(tmp_path): source = """ import pytask @@ -60,10 +60,10 @@ def task_compile_latex_document(): """ tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source)) - for name, content in [ + for name, content in ( ("document_1.tex", "Like a worn out recording"), ("document_2.tex", "Of a favorite song"), - ]: + ): latex_source = rf""" \documentclass{{report}} \begin{{document}} @@ -81,7 +81,7 @@ def task_compile_latex_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parametrizing_latex_options_w_parametrize(tmp_path): task_source = """ import pytask @@ -128,7 +128,7 @@ def task_compile_latex_document(): @needs_latexmk @skip_on_github_actions_with_win -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_parametrizing_latex_options_w_loop(tmp_path): source = """ import pytask From ab584d7167f3263a78585fa8a7ae08eddaa32e64 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 9 Jan 2023 19:31:14 +0100 Subject: [PATCH 4/5] Fix error. --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index dd67fec..623972e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,3 +7,5 @@ exclude tox.ini include README.md include LICENSE + +recursive-include src *.typed From 3fdeb6431dd81a2bd1f3cc525547efb9d85500a0 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 9 Jan 2023 19:44:34 +0100 Subject: [PATCH 5/5] remove pyupgrade. --- .pre-commit-config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6bc8942..8d4b16b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,11 +25,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: [--py37-plus] - repo: https://github.com/asottile/reorder_python_imports rev: v3.9.0 hooks: