cook-build 0.6.2__py3-none-any.whl → 0.6.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cook/contexts.py CHANGED
@@ -33,7 +33,8 @@ Custom contexts can be implemented by inheriting from :class:`.Context` and impl
33
33
  from __future__ import annotations
34
34
  from pathlib import Path
35
35
  from types import ModuleType
36
- from typing import Callable, TYPE_CHECKING
36
+ from typing import Callable, TYPE_CHECKING, TypeVar
37
+ import warnings
37
38
  from . import actions
38
39
  from . import manager as manager_
39
40
  from . import task as task_
@@ -44,6 +45,8 @@ if TYPE_CHECKING:
44
45
  from .manager import Manager
45
46
  from .task import Task
46
47
 
48
+ ContextT = TypeVar("ContextT", bound="Context")
49
+
47
50
 
48
51
  class Context:
49
52
  """
@@ -56,7 +59,7 @@ class Context:
56
59
  def __init__(self, manager: "Manager | None" = None) -> None:
57
60
  self.manager = manager or manager_.Manager.get_instance()
58
61
 
59
- def __enter__(self) -> Context:
62
+ def __enter__(self: ContextT) -> ContextT:
60
63
  self.manager.contexts.append(self)
61
64
  return self
62
65
 
@@ -214,10 +217,21 @@ class normalize_dependencies(Context):
214
217
  task_dependencies = task.task_dependencies
215
218
  for dependency in task.dependencies:
216
219
  if isinstance(dependency, (task_.Task, create_group)):
217
- task_dependencies.append(dependency) # pyright: ignore[reportArgumentType]
220
+ warnings.warn(
221
+ "Passing Task objects to 'dependencies' is deprecated. Use "
222
+ "'task_dependencies' instead.",
223
+ DeprecationWarning,
224
+ stacklevel=4,
225
+ )
226
+ task_dependencies.append(dependency)
218
227
  else:
219
228
  dependencies.append(dependency)
220
- task.dependencies = [Path(x) for x in dependencies] # pyright: ignore[reportAttributeAccessIssue]
229
+ # Convert all remaining dependencies (strings) to Path objects.
230
+ # After normalization, dependencies list contains only Path objects, but the
231
+ # Task.dependencies attribute is typed as list[PathOrStr | Task] to accept broader
232
+ # input before normalization. The isinstance checks in controller.py and manager.py
233
+ # validate this assumption at runtime.
234
+ task.dependencies = [Path(x) for x in dependencies] # type: ignore[assignment]
221
235
 
222
236
  # Unpack group dependencies and look up tasks by name.
223
237
  task_dependencies = []
cook/controller.py CHANGED
@@ -109,6 +109,12 @@ class Controller:
109
109
  """
110
110
  dependencies = []
111
111
  for dependency in task.dependencies:
112
+ # Dependencies should be Path or str after normalize_dependencies runs.
113
+ # Tasks should have been moved to task_dependencies.
114
+ assert isinstance(dependency, (Path, str)), (
115
+ f"Unexpected dependency type '{type(dependency)}'. Dependencies "
116
+ "should be 'Path' or 'str' after 'normalize_dependencies'."
117
+ )
112
118
  dependency = Path(dependency).resolve()
113
119
  if not dependency.is_file():
114
120
  LOGGER.debug("dependency %s of %s is missing", dependency, task)
cook/manager.py CHANGED
@@ -96,8 +96,14 @@ class Manager:
96
96
  f"tasks {task} and {other} both have target {path}"
97
97
  )
98
98
  task_by_target[path] = task
99
- for path in task.dependencies:
100
- path = Path(path).resolve()
99
+ for dependency in task.dependencies:
100
+ # Dependencies should be Path or str after normalize_dependencies runs.
101
+ # Tasks should have been moved to task_dependencies.
102
+ assert isinstance(dependency, (Path, str)), (
103
+ f"Unexpected dependency type '{type(dependency)}'. Dependencies "
104
+ "should be 'Path' or 'str' after 'normalize_dependencies'."
105
+ )
106
+ path = Path(dependency).resolve()
101
107
  tasks_by_file_dependency.setdefault(path, set()).add(task)
102
108
 
103
109
  # Build a directed graph of dependencies based on files produced and consumed by tasks.
@@ -132,8 +138,8 @@ def create_task(
132
138
  name: str,
133
139
  *,
134
140
  action: "Action | str | None" = None,
135
- targets: list["Path"] | None = None,
136
- dependencies: list["Path"] | None = None,
141
+ targets: list["Path | str"] | None = None,
142
+ dependencies: list["Path | str | Task"] | None = None,
137
143
  task_dependencies: list["Task"] | None = None,
138
144
  location: tuple[str, int] | None = None,
139
145
  ) -> "Task":
cook/task.py CHANGED
@@ -19,7 +19,7 @@ class Task:
19
19
  self,
20
20
  name: str,
21
21
  *,
22
- dependencies: list["PathOrStr"] | None = None,
22
+ dependencies: list["PathOrStr | Task"] | None = None,
23
23
  targets: list["PathOrStr"] | None = None,
24
24
  action: Action | None = None,
25
25
  task_dependencies: list[Task] | None = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cook-build
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: A task-centric build system with simple declarative recipes specified in Python
5
5
  Author: Till Hoffmann
6
6
  License: BSD-3-Clause
@@ -0,0 +1,14 @@
1
+ cook/__init__.py,sha256=uNRvyxT6-XuoAMdDujWYa_4ZW0ppAiom6tsxMovZ-A0,180
2
+ cook/__main__.py,sha256=jcXYDWbMkRU24ZrrAZGrsT2wQ7nhimpigrPjfrMsRtk,12925
3
+ cook/actions.py,sha256=erjjDKC45kQpv_Qb2V3OCGvrrphka4Ytj78RPEvs8Uc,6718
4
+ cook/contexts.py,sha256=e3bddOaR8OLhPh38-U5b-u9D83NXlbQU0Hn7UvYaITI,10717
5
+ cook/controller.py,sha256=z20sKMzCG-wJziMIn3XeDmmvu7IUogx-iDI4sGSrwzs,16132
6
+ cook/manager.py,sha256=FAy8CKIMOx5liYNnaDTgnC5YZm1aqWy3pCIGiP8Hv2w,6118
7
+ cook/task.py,sha256=ioPuQ8jp09BY9VhKn2cC6Q8G17W-1e4q4kj2GD4Zs8k,1388
8
+ cook/util.py,sha256=hpMxxHnmJRfCUUAzkwMQU4kF_JAcEBFVpvPsHxOOY2U,2681
9
+ cook_build-0.6.3.dist-info/licenses/LICENSE,sha256=3Nuj_WTTcz7JDg4-9EzNf6vHlKRWpdLUccg-pvoZ3WE,1500
10
+ cook_build-0.6.3.dist-info/METADATA,sha256=RMt42OtLjrg1Z4iUvFvD1oRv2TMj-_mpQM_kD9LczMk,4586
11
+ cook_build-0.6.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ cook_build-0.6.3.dist-info/entry_points.txt,sha256=5UP0ZmmxSNKevTVISUJxmdXEQsKrI4n54OQYkjrdX2c,48
13
+ cook_build-0.6.3.dist-info/top_level.txt,sha256=ewNQIn2oRSYV98vAsUnw88u2Q8XHKhAz70ed2PEdR2c,5
14
+ cook_build-0.6.3.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- cook/__init__.py,sha256=uNRvyxT6-XuoAMdDujWYa_4ZW0ppAiom6tsxMovZ-A0,180
2
- cook/__main__.py,sha256=jcXYDWbMkRU24ZrrAZGrsT2wQ7nhimpigrPjfrMsRtk,12925
3
- cook/actions.py,sha256=erjjDKC45kQpv_Qb2V3OCGvrrphka4Ytj78RPEvs8Uc,6718
4
- cook/contexts.py,sha256=Gw2zfiyVFaJ5p2vAFrFJEQ4f521GznueM2Y2ddiG3iE,10047
5
- cook/controller.py,sha256=BYsYxPqEWDwYLAG7-cHzzTuqIvFunGGSge1XAbDk9xs,15753
6
- cook/manager.py,sha256=vt-PoZ8IOmPIGbe9xeqUrZ4VJf2Gj5KucwjQzc5YUZ4,5684
7
- cook/task.py,sha256=0OGzVKKezo8x6nX80OpLnGsqCG8mIE7oUaBgSqv3m0M,1381
8
- cook/util.py,sha256=hpMxxHnmJRfCUUAzkwMQU4kF_JAcEBFVpvPsHxOOY2U,2681
9
- cook_build-0.6.2.dist-info/licenses/LICENSE,sha256=3Nuj_WTTcz7JDg4-9EzNf6vHlKRWpdLUccg-pvoZ3WE,1500
10
- cook_build-0.6.2.dist-info/METADATA,sha256=0H6_FzoAJ-Qi2zM4TnHsQO99iiD0msxHdKRiN0M9nVw,4586
11
- cook_build-0.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- cook_build-0.6.2.dist-info/entry_points.txt,sha256=5UP0ZmmxSNKevTVISUJxmdXEQsKrI4n54OQYkjrdX2c,48
13
- cook_build-0.6.2.dist-info/top_level.txt,sha256=ewNQIn2oRSYV98vAsUnw88u2Q8XHKhAz70ed2PEdR2c,5
14
- cook_build-0.6.2.dist-info/RECORD,,