Skip to content

Commit d765181

Browse files
committed
Update ty to 0.0.65
1 parent 0dc0f43 commit d765181

3 files changed

Lines changed: 35 additions & 24 deletions

File tree

‎src/_pytask/data_catalog.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from dataclasses import dataclass
1414
from dataclasses import field
1515
from pathlib import Path
16+
from typing import TYPE_CHECKING
1617
from typing import Any
18+
from typing import cast
1719

1820
from _pytask.config_utils import find_project_root_and_config
1921
from _pytask.data_catalog_utils import DATA_CATALOG_NAME_FIELD
@@ -25,6 +27,9 @@
2527
from _pytask.pluginmanager import storage
2628
from _pytask.session import Session
2729

30+
if TYPE_CHECKING:
31+
from collections.abc import Callable
32+
2833
__all__ = ["DataCatalog"]
2934

3035

@@ -118,13 +123,17 @@ def add(self, name: str, node: PNode | PProvisionalNode | Any = None) -> None:
118123

119124
if node is None:
120125
filename = hashlib.sha256(name.encode()).hexdigest()
126+
# Plugins can provide node classes with different keyword-only
127+
# constructors. The path-node check below selects the supported call
128+
# shape at runtime.
129+
node_factory = cast("Callable[..., PNode]", self.default_node)
121130
if _is_path_node_type(self.default_node):
122131
assert self.path is not None
123-
self._entries[name] = self.default_node(
132+
self._entries[name] = node_factory(
124133
name=name, path=self.path / f"{filename}.pkl"
125134
)
126135
else:
127-
self._entries[name] = self.default_node(name=name)
136+
self._entries[name] = node_factory(name=name)
128137
assert self.path is not None
129138
self.path.joinpath(f"{filename}-node.pkl").write_bytes(
130139
pickle.dumps(self._entries[name])

‎src/_pytask/task_utils.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ def wrapper(func: T) -> TaskDecorated[T]:
230230
# collection when the function definition is overwritten in a loop.
231231
COLLECTED_TASKS[path].append(unwrapped)
232232

233-
return unwrapped
233+
# Runtime validation and metadata attachment establish both parts of the
234+
# intersection, but the generic relationship cannot be narrowed automatically.
235+
return cast("TaskDecorated[T]", unwrapped)
234236

235237
# When decorator is used without parentheses, call wrapper directly.
236238
if _is_task_decorator_target(name) and kwargs is None:

‎uv.lock‎

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)