55import warnings
66from pathlib import Path
77from subprocess import CalledProcessError
8+ from typing import TYPE_CHECKING
89from typing import Any
910from typing import Callable
10- from typing import Sequence
1111
1212import latex_dependency_scanner as lds
1313from pytask import Mark
3333from pytask_latex import compilation_steps as cs
3434from pytask_latex .utils import to_list
3535
36+ if TYPE_CHECKING :
37+ from collections .abc import Sequence
38+
3639
3740def latex (
3841 * ,
@@ -219,10 +222,10 @@ def pytask_collect_task(
219222def pytask_collect_modify_tasks (session : Session , tasks : list [PTask ]) -> None :
220223 """Add dependencies from from LaTeX documents to tasks."""
221224 if session .config ["infer_latex_dependencies" ]:
222- all_products = {
225+ all_products = { # type: ignore[var-annotated]
223226 product .path
224227 for task in tasks
225- for product in tree_leaves (task .produces )
228+ for product in tree_leaves (task .produces ) # type: ignore[arg-type]
226229 if isinstance (product , PPathNode )
227230 }
228231 latex_tasks = [task for task in tasks if has_mark (task , "latex" )]
@@ -255,7 +258,7 @@ def _add_latex_dependencies_retroactively(
255258 # Scan the LaTeX document for included files.
256259 try :
257260 scanned_deps = set (
258- lds .scan (task .depends_on ["_path_to_tex" ].path ) # type: ignore[attr-defined ]
261+ lds .scan (task .depends_on ["_path_to_tex" ].path ) # type: ignore[arg-type ]
259262 )
260263 except Exception : # noqa: BLE001
261264 warnings .warn (
@@ -265,8 +268,10 @@ def _add_latex_dependencies_retroactively(
265268
266269 # Remove duplicated dependencies which have already been added by the user and those
267270 # which do not exist.
268- task_deps = {
269- i .path for i in tree_leaves (task .depends_on ) if isinstance (i , PPathNode )
271+ task_deps = { # type: ignore[var-annotated]
272+ i .path
273+ for i in tree_leaves (task .depends_on ) # type: ignore[arg-type]
274+ if isinstance (i , PPathNode )
270275 }
271276 additional_deps = scanned_deps - task_deps
272277 new_deps = [i for i in additional_deps if i in all_products or i .exists ()]
@@ -287,9 +292,9 @@ def _add_latex_dependencies_retroactively(
287292 task_name = task .name ,
288293 ),
289294 ),
290- new_deps ,
295+ new_deps , # type: ignore[arg-type]
291296 )
292- task .depends_on ["_scanned_dependencies" ] = collected_dependencies
297+ task .depends_on ["_scanned_dependencies" ] = collected_dependencies # type: ignore[assignment]
293298
294299 # Mark the task as being delayed to avoid conflicts with unmatched dependencies.
295300 task .markers .append (Mark ("try_last" , (), {}))
0 commit comments