Skip to content

Commit

Permalink
Rename to from_annot.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Aug 5, 2023
1 parent 4d9c4ac commit 6017b82
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/_pytask/collect_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,5 @@ def _evolve_instance(x: Any, instance_from_annot: Node | None) -> Any:
if not instance_from_annot:
return x

instance_from_annot.set_value(x)
instance_from_annot.from_annot(x)
return instance_from_annot
2 changes: 1 addition & 1 deletion src/_pytask/node_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load(self) -> Any:
def save(self, value: Any) -> Any:
...

def set_value(self, value: Any) -> Any:
def from_annot(self, value: Any) -> Any:
...


Expand Down
4 changes: 2 additions & 2 deletions src/_pytask/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PathNode(Node):
def path(self) -> Path:
return self.value

def set_value(self, value: Path) -> None:
def from_annot(self, value: Path) -> None:
"""Set path and if other attributes are not set, set sensible defaults."""
if not isinstance(value, Path):
raise TypeError("'value' must be a 'pathlib.Path'.")
Expand Down Expand Up @@ -173,7 +173,7 @@ def load(self) -> Any:
def save(self, value: Any) -> NoReturn:
raise NotImplementedError

def set_value(self, value: Any) -> None:
def from_annot(self, value: Any) -> None:
self.value = value

def state(self) -> str | None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_collect_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def state(self):
def load(self): ...
def save(self, value): ...
def set_value(self, value): ...
def from_annot(self, value): ...
def task_example(
data = CustomNode("custom", "text"),
Expand Down Expand Up @@ -572,7 +572,7 @@ def save(self, value):
with self.path.open("wb") as f:
pickle.dump(value, f)
def set_value(self, value): ...
def from_annot(self, value): ...
_PATH = Path(__file__).parent.joinpath("in.pkl")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def load(self) -> Any:
def save(self, value: Any) -> None:
self.path.write_bytes(pickle.dumps(value))
def set_value(self, value: Any) -> None: ...
def from_annot(self, value: Any) -> None: ...
node = PickleNode("pickled_data", Path(__file__).parent.joinpath("data.pkl"))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_node_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def load(self):
def save(self, value):
self.value = value
def set_value(self, value): ...
def from_annot(self, value): ...
def task_example(
Expand Down Expand Up @@ -70,7 +70,7 @@ def save(self, value):
with self.path.open("wb") as f:
pickle.dump(value, f)
def set_value(self, value): ...
def from_annot(self, value): ...
_PATH = Path(__file__).parent.joinpath("in.pkl")
Expand Down

0 comments on commit 6017b82

Please sign in to comment.