From c1b4b68834fc70a9cbbc1cfaad4a9cf43bc5a08b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 14 Mar 2022 19:45:31 +0100 Subject: [PATCH 1/2] Deprecate the old api. --- CHANGES.rst | 6 ++++ src/pytask_latex/collect.py | 30 ++++++---------- tests/test_execute.py | 68 ------------------------------------- tests/test_parallel.py | 55 ------------------------------ tests/test_parametrize.py | 40 ---------------------- 5 files changed, 17 insertions(+), 182 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7c96190..525d51e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,12 @@ all releases are available on `Anaconda.org `_. +0.2.0 - 2022-xx-xx +------------------ + +- :pull:`34` deprecates the old api. + + 0.1.2 - 2022-xx-xx ------------------ diff --git a/src/pytask_latex/collect.py b/src/pytask_latex/collect.py index 98ac9f0..c2d0acd 100644 --- a/src/pytask_latex/collect.py +++ b/src/pytask_latex/collect.py @@ -3,11 +3,9 @@ import copy import functools -import warnings from subprocess import CalledProcessError from typing import Any from typing import Callable -from typing import Iterable from typing import Sequence import latex_dependency_scanner as lds @@ -41,7 +39,6 @@ def task_func(): def latex( - options: str | Iterable[str] | None = None, *, compilation_steps: str | Callable[..., Any] @@ -59,22 +56,17 @@ def latex( """ compilation_steps = ["latexmk"] if compilation_steps is None else compilation_steps - if options is not None: - warnings.warn(_DEPRECATION_WARNING, DeprecationWarning) - out = [cs.latexmk(options)] - - else: - out = [] - for step in to_list(compilation_steps): - if isinstance(step, str): - parsed_step = getattr(cs, step) - if parsed_step is None: - raise ValueError(f"Compilation step {step!r} is unknown.") - out.append(parsed_step()) - elif callable(step): - out.append(step) - else: - raise ValueError(f"Compilation step {step!r} is not a valid step.") + out = [] + for step in to_list(compilation_steps): + if isinstance(step, str): + parsed_step = getattr(cs, step) + if parsed_step is None: + raise ValueError(f"Compilation step {step!r} is unknown.") + out.append(parsed_step()) + elif callable(step): + out.append(step) + else: + raise ValueError(f"Compilation step {step!r} is not a valid step.") return out diff --git a/tests/test_execute.py b/tests/test_execute.py index e30a9b8..5a61973 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -249,39 +249,6 @@ def task_compile_document(): def test_compile_latex_document_w_xelatex(runner, tmp_path): task_source = """ import pytask - - @pytask.mark.latex( - ["--xelatex", "--interaction=nonstopmode", "--synctex=1", "--cd"] - ) - @pytask.mark.depends_on("document.tex") - @pytask.mark.produces("document.pdf") - def task_compile_document(): - pass - - """ - tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(task_source)) - - latex_source = r""" - \documentclass{report} - \begin{document} - I got, I got, I got, I got loyalty, got royalty inside my DNA. - \end{document} - """ - tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source)) - - with pytest.warns(DeprecationWarning, match="The old syntax"): - result = runner.invoke(cli, [tmp_path.as_posix()]) - - assert result.exit_code == 0 - assert tmp_path.joinpath("document.pdf").exists() - - -@needs_latexmk -@skip_on_github_actions_with_win -@pytest.mark.end_to_end -def test_compile_latex_document_w_xelatex_new_api(runner, tmp_path): - task_source = """ - import pytask from pytask_latex import compilation_steps @pytask.mark.latex( @@ -428,41 +395,6 @@ def test_compile_document_w_wrong_flag(tmp_path): """Test that wrong flags raise errors.""" tmp_path.joinpath("sub").mkdir(parents=True) - task_source = """ - import pytask - - @pytask.mark.latex(["--wrong-flag"]) - @pytask.mark.depends_on("document.tex") - @pytask.mark.produces("out/document.pdf") - def task_compile_document(): - pass - - """ - tmp_path.joinpath("sub", "task_dummy.py").write_text(textwrap.dedent(task_source)) - - latex_source = r""" - \documentclass{report} - \begin{document} - The book of love is long and boring ... - \end{document} - """ - tmp_path.joinpath("sub", "document.tex").write_text(textwrap.dedent(latex_source)) - - with pytest.warns(DeprecationWarning, match="The old syntax"): - session = main({"paths": tmp_path}) - - assert session.exit_code == 1 - assert len(session.tasks) == 1 - assert isinstance(session.execution_reports[0].exc_info[1], RuntimeError) - - -@needs_latexmk -@skip_on_github_actions_with_win -@pytest.mark.end_to_end -def test_compile_document_w_wrong_flag_new_api(tmp_path): - """Test that wrong flags raise errors.""" - tmp_path.joinpath("sub").mkdir(parents=True) - task_source = """ import pytask from pytask_latex import compilation_steps diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 401e719..60f7a5d 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -86,61 +86,6 @@ def task_compile_latex_document(): def test_parallel_parametrization_over_source_file(runner, tmp_path): source = """ import pytask - - @pytask.mark.depends_on("document.tex") - @pytask.mark.parametrize( - "produces, latex", - [ - ( - "document.pdf", - ("--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd") - ), - ( - "document.dvi", - ("--dvi", "--interaction=nonstopmode", "--synctex=1", "--cd") - ), - ], - ) - def task_compile_latex_document(): - pass - """ - tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source)) - - latex_source = r""" - \documentclass{report} - \begin{document} - Ma il mio mistero e chiuso in me - \end{document} - """ - tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source)) - - start = time.time() - with pytest.warns(DeprecationWarning, match="The old syntax"): - result = runner.invoke(cli, [tmp_path.as_posix()]) - - assert result.exit_code == 0 - duration_normal = time.time() - start - - for name in ["document.pdf", "document.dvi"]: - tmp_path.joinpath(name).unlink() - - start = time.time() - with pytest.warns(DeprecationWarning, match="The old syntax"): - result = runner.invoke(cli, [tmp_path.as_posix(), "-n", 2]) - - assert result.exit_code == 0 - duration_parallel = time.time() - start - - assert duration_parallel < duration_normal - - -@xfail_on_remote -@needs_latexmk -@skip_on_github_actions_with_win -@pytest.mark.end_to_end -def test_parallel_parametrization_over_source_file_new_api(runner, tmp_path): - source = """ - import pytask from pytask_latex import compilation_steps @pytask.mark.depends_on("document.tex") diff --git a/tests/test_parametrize.py b/tests/test_parametrize.py index b4a9e67..153c60e 100644 --- a/tests/test_parametrize.py +++ b/tests/test_parametrize.py @@ -73,46 +73,6 @@ def task_compile_latex_document(): def test_parametrizing_latex_options(tmp_path): task_source = """ import pytask - - @pytask.mark.parametrize("depends_on, produces, latex", [ - ( - "document.tex", - "document.pdf", - ("--interaction=nonstopmode", "--pdf", "--cd") - ), - ( - "document.tex", - "document.dvi", - ("--interaction=nonstopmode", "--dvi", "--cd") - ), - ]) - def task_compile_latex_document(): - pass - """ - tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(task_source)) - - latex_source = r""" - \documentclass{report} - \begin{document} - I can't stop this feeling. Deep inside of me. - \end{document} - """ - tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source)) - - with pytest.warns(DeprecationWarning, match="The old syntax"): - session = main({"paths": tmp_path}) - - assert session.exit_code == 0 - assert tmp_path.joinpath("document.pdf").exists() - assert tmp_path.joinpath("document.dvi").exists() - - -@needs_latexmk -@skip_on_github_actions_with_win -@pytest.mark.end_to_end -def test_parametrizing_latex_options_new_api(tmp_path): - task_source = """ - import pytask from pytask_latex import compilation_steps @pytask.mark.parametrize("depends_on, produces, latex", [ From ad0858c39e3b25576c96da9ed0e5f0c808f6c44e Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 15 Apr 2022 20:34:53 +0200 Subject: [PATCH 2/2] Change status. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 52a377b..42a0ae6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ license = MIT license_file = LICENSE platforms = any classifiers = - Development Status :: 3 - Alpha + Development Status :: 4 - Beta License :: OSI Approved :: MIT License Operating System :: OS Independent Programming Language :: Python :: 3