Skip to content

Commit c1b4b68

Browse files
committed
Deprecate the old api.
1 parent ed179b5 commit c1b4b68

File tree

5 files changed

+17
-182
lines changed

5 files changed

+17
-182
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ all releases are available on `Anaconda.org
77
<https://anaconda.org/conda-forge/pytask-latex>`_.
88

99

10+
0.2.0 - 2022-xx-xx
11+
------------------
12+
13+
- :pull:`34` deprecates the old api.
14+
15+
1016
0.1.2 - 2022-xx-xx
1117
------------------
1218

src/pytask_latex/collect.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
import copy
55
import functools
6-
import warnings
76
from subprocess import CalledProcessError
87
from typing import Any
98
from typing import Callable
10-
from typing import Iterable
119
from typing import Sequence
1210

1311
import latex_dependency_scanner as lds
@@ -41,7 +39,6 @@ def task_func():
4139

4240

4341
def latex(
44-
options: str | Iterable[str] | None = None,
4542
*,
4643
compilation_steps: str
4744
| Callable[..., Any]
@@ -59,22 +56,17 @@ def latex(
5956
"""
6057
compilation_steps = ["latexmk"] if compilation_steps is None else compilation_steps
6158

62-
if options is not None:
63-
warnings.warn(_DEPRECATION_WARNING, DeprecationWarning)
64-
out = [cs.latexmk(options)]
65-
66-
else:
67-
out = []
68-
for step in to_list(compilation_steps):
69-
if isinstance(step, str):
70-
parsed_step = getattr(cs, step)
71-
if parsed_step is None:
72-
raise ValueError(f"Compilation step {step!r} is unknown.")
73-
out.append(parsed_step())
74-
elif callable(step):
75-
out.append(step)
76-
else:
77-
raise ValueError(f"Compilation step {step!r} is not a valid step.")
59+
out = []
60+
for step in to_list(compilation_steps):
61+
if isinstance(step, str):
62+
parsed_step = getattr(cs, step)
63+
if parsed_step is None:
64+
raise ValueError(f"Compilation step {step!r} is unknown.")
65+
out.append(parsed_step())
66+
elif callable(step):
67+
out.append(step)
68+
else:
69+
raise ValueError(f"Compilation step {step!r} is not a valid step.")
7870

7971
return out
8072

tests/test_execute.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -249,39 +249,6 @@ def task_compile_document():
249249
def test_compile_latex_document_w_xelatex(runner, tmp_path):
250250
task_source = """
251251
import pytask
252-
253-
@pytask.mark.latex(
254-
["--xelatex", "--interaction=nonstopmode", "--synctex=1", "--cd"]
255-
)
256-
@pytask.mark.depends_on("document.tex")
257-
@pytask.mark.produces("document.pdf")
258-
def task_compile_document():
259-
pass
260-
261-
"""
262-
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(task_source))
263-
264-
latex_source = r"""
265-
\documentclass{report}
266-
\begin{document}
267-
I got, I got, I got, I got loyalty, got royalty inside my DNA.
268-
\end{document}
269-
"""
270-
tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source))
271-
272-
with pytest.warns(DeprecationWarning, match="The old syntax"):
273-
result = runner.invoke(cli, [tmp_path.as_posix()])
274-
275-
assert result.exit_code == 0
276-
assert tmp_path.joinpath("document.pdf").exists()
277-
278-
279-
@needs_latexmk
280-
@skip_on_github_actions_with_win
281-
@pytest.mark.end_to_end
282-
def test_compile_latex_document_w_xelatex_new_api(runner, tmp_path):
283-
task_source = """
284-
import pytask
285252
from pytask_latex import compilation_steps
286253
287254
@pytask.mark.latex(
@@ -428,41 +395,6 @@ def test_compile_document_w_wrong_flag(tmp_path):
428395
"""Test that wrong flags raise errors."""
429396
tmp_path.joinpath("sub").mkdir(parents=True)
430397

431-
task_source = """
432-
import pytask
433-
434-
@pytask.mark.latex(["--wrong-flag"])
435-
@pytask.mark.depends_on("document.tex")
436-
@pytask.mark.produces("out/document.pdf")
437-
def task_compile_document():
438-
pass
439-
440-
"""
441-
tmp_path.joinpath("sub", "task_dummy.py").write_text(textwrap.dedent(task_source))
442-
443-
latex_source = r"""
444-
\documentclass{report}
445-
\begin{document}
446-
The book of love is long and boring ...
447-
\end{document}
448-
"""
449-
tmp_path.joinpath("sub", "document.tex").write_text(textwrap.dedent(latex_source))
450-
451-
with pytest.warns(DeprecationWarning, match="The old syntax"):
452-
session = main({"paths": tmp_path})
453-
454-
assert session.exit_code == 1
455-
assert len(session.tasks) == 1
456-
assert isinstance(session.execution_reports[0].exc_info[1], RuntimeError)
457-
458-
459-
@needs_latexmk
460-
@skip_on_github_actions_with_win
461-
@pytest.mark.end_to_end
462-
def test_compile_document_w_wrong_flag_new_api(tmp_path):
463-
"""Test that wrong flags raise errors."""
464-
tmp_path.joinpath("sub").mkdir(parents=True)
465-
466398
task_source = """
467399
import pytask
468400
from pytask_latex import compilation_steps

tests/test_parallel.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -86,61 +86,6 @@ def task_compile_latex_document():
8686
def test_parallel_parametrization_over_source_file(runner, tmp_path):
8787
source = """
8888
import pytask
89-
90-
@pytask.mark.depends_on("document.tex")
91-
@pytask.mark.parametrize(
92-
"produces, latex",
93-
[
94-
(
95-
"document.pdf",
96-
("--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd")
97-
),
98-
(
99-
"document.dvi",
100-
("--dvi", "--interaction=nonstopmode", "--synctex=1", "--cd")
101-
),
102-
],
103-
)
104-
def task_compile_latex_document():
105-
pass
106-
"""
107-
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
108-
109-
latex_source = r"""
110-
\documentclass{report}
111-
\begin{document}
112-
Ma il mio mistero e chiuso in me
113-
\end{document}
114-
"""
115-
tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source))
116-
117-
start = time.time()
118-
with pytest.warns(DeprecationWarning, match="The old syntax"):
119-
result = runner.invoke(cli, [tmp_path.as_posix()])
120-
121-
assert result.exit_code == 0
122-
duration_normal = time.time() - start
123-
124-
for name in ["document.pdf", "document.dvi"]:
125-
tmp_path.joinpath(name).unlink()
126-
127-
start = time.time()
128-
with pytest.warns(DeprecationWarning, match="The old syntax"):
129-
result = runner.invoke(cli, [tmp_path.as_posix(), "-n", 2])
130-
131-
assert result.exit_code == 0
132-
duration_parallel = time.time() - start
133-
134-
assert duration_parallel < duration_normal
135-
136-
137-
@xfail_on_remote
138-
@needs_latexmk
139-
@skip_on_github_actions_with_win
140-
@pytest.mark.end_to_end
141-
def test_parallel_parametrization_over_source_file_new_api(runner, tmp_path):
142-
source = """
143-
import pytask
14489
from pytask_latex import compilation_steps
14590
14691
@pytask.mark.depends_on("document.tex")

tests/test_parametrize.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -73,46 +73,6 @@ def task_compile_latex_document():
7373
def test_parametrizing_latex_options(tmp_path):
7474
task_source = """
7575
import pytask
76-
77-
@pytask.mark.parametrize("depends_on, produces, latex", [
78-
(
79-
"document.tex",
80-
"document.pdf",
81-
("--interaction=nonstopmode", "--pdf", "--cd")
82-
),
83-
(
84-
"document.tex",
85-
"document.dvi",
86-
("--interaction=nonstopmode", "--dvi", "--cd")
87-
),
88-
])
89-
def task_compile_latex_document():
90-
pass
91-
"""
92-
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(task_source))
93-
94-
latex_source = r"""
95-
\documentclass{report}
96-
\begin{document}
97-
I can't stop this feeling. Deep inside of me.
98-
\end{document}
99-
"""
100-
tmp_path.joinpath("document.tex").write_text(textwrap.dedent(latex_source))
101-
102-
with pytest.warns(DeprecationWarning, match="The old syntax"):
103-
session = main({"paths": tmp_path})
104-
105-
assert session.exit_code == 0
106-
assert tmp_path.joinpath("document.pdf").exists()
107-
assert tmp_path.joinpath("document.dvi").exists()
108-
109-
110-
@needs_latexmk
111-
@skip_on_github_actions_with_win
112-
@pytest.mark.end_to_end
113-
def test_parametrizing_latex_options_new_api(tmp_path):
114-
task_source = """
115-
import pytask
11676
from pytask_latex import compilation_steps
11777
11878
@pytask.mark.parametrize("depends_on, produces, latex", [

0 commit comments

Comments
 (0)