From bfde527582e873c8620e11202a0ef4c4e4da213f Mon Sep 17 00:00:00 2001 From: huyenngn Date: Tue, 26 Mar 2024 17:28:10 +0100 Subject: [PATCH] refactor(decl): Rename modify to set --- capellambse/decl.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/capellambse/decl.py b/capellambse/decl.py index aa8ae7f96..0875357d8 100644 --- a/capellambse/decl.py +++ b/capellambse/decl.py @@ -218,6 +218,17 @@ def _operate_modify( promises: dict[Promise, capellambse.ModelObject], parent: capellambse.ModelObject, modifications: dict[str, t.Any], +) -> cabc.Generator[_OperatorResult, t.Any, None]: + import warnings + + warnings.warn("Use 'extend' instead of 'create' in declarative YAML") + yield from _operate_set(promises, parent, modifications) + + +def _operate_set( + promises: dict[Promise, capellambse.ModelObject], + parent: capellambse.ModelObject, + modifications: dict[str, t.Any], ) -> cabc.Generator[_OperatorResult, t.Any, None]: for attr, value in modifications.items(): if isinstance(value, (list, Promise, _ObjectFinder)): @@ -264,7 +275,7 @@ def _operate_sync( if sync := obj.pop("sync", None): yield from _operate_sync(promises, candidate, sync) if mods := obj.pop("set", None): - yield from _operate_modify(promises, candidate, mods) + yield from _operate_set(promises, candidate, mods) if ext := obj.pop("extend", None): yield from _operate_extend(promises, candidate, ext) promise: str | Promise | None = obj.get("promise_id") @@ -382,6 +393,7 @@ class _NoObjectFoundError(ValueError): ("create", _operate_create), ("extend", _operate_extend), ("modify", _operate_modify), + ("set", _operate_set), ("sync", _operate_sync), ("delete", _operate_delete), )