diff --git a/tiled/_tests/test_writing.py b/tiled/_tests/test_writing.py index b643969f3..66cd8516b 100644 --- a/tiled/_tests/test_writing.py +++ b/tiled/_tests/test_writing.py @@ -321,7 +321,7 @@ def test_merge_patching(tree): client = from_context(context) ac = client.write_array([1, 2, 3], metadata={"a": 0, "b": 2}, specs=["spec1"]) ac.patch_metadata( - md_patch={"a": 1, "c": 3}, content_type=patch_mimetypes.MERGE_PATCH + metadata_patch={"a": 1, "c": 3}, content_type=patch_mimetypes.MERGE_PATCH ) assert dict(ac.metadata) == {"a": 1, "b": 2, "c": 3} assert ac.specs[0].name == "spec1" @@ -345,7 +345,7 @@ def test_json_patching(tree): client = from_context(context) ac = client.write_array([1, 2, 3], metadata={"a": 0, "b": 2}, specs=["spec1"]) ac.patch_metadata( - md_patch=[ + metadata_patch=[ {"op": "add", "path": "/c", "value": 3}, {"op": "replace", "path": "/a", "value": 1}, ], diff --git a/tiled/client/base.py b/tiled/client/base.py index fb306a583..f3fbf3e9c 100644 --- a/tiled/client/base.py +++ b/tiled/client/base.py @@ -11,14 +11,7 @@ from ..structures.core import STRUCTURE_TYPES, Spec, StructureFamily from ..structures.data_source import DataSource -from ..utils import ( - UNCHANGED, - DictView, - ListView, - OneShotCachedMap, - patch_mimetypes, - safe_json_dump, -) +from ..utils import UNCHANGED, DictView, ListView, patch_mimetypes, safe_json_dump from .metadata_update import apply_update_patch from .utils import MSGPACK_MIME_TYPE, handle_error @@ -450,10 +443,10 @@ def update_metadata(self, metadata=None, specs=None): else: raise ValueError("Duplicate specs provided after [metadata, specs]") - md_patch, specs_patch = self.build_metadata_patches( + metadata_patch, specs_patch = self.build_metadata_patches( metadata=metadata, specs=specs ) - self.patch_metadata(md_patch=md_patch, specs_patch=specs_patch) + self.patch_metadata(metadata_patch=metadata_patch, specs_patch=specs_patch) def build_metadata_patches(self, metadata=None, specs=None): """ @@ -562,7 +555,10 @@ def _build_metadata_revisions(self): return self._metadata_revisions def patch_metadata( - self, md_patch=None, specs_patch=None, content_type=patch_mimetypes.JSON_PATCH + self, + metadata_patch=None, + specs_patch=None, + content_type=patch_mimetypes.JSON_PATCH, ): """ EXPERIMENTAL: Patch metadata using a JSON Patch (RFC6902). @@ -571,7 +567,7 @@ def patch_metadata( Parameters ---------- - md_patch : List[dict], optional + metadata_patch : List[dict], optional JSON-serializable patch to be applied to metadata specs_patch : List[dict], optional JSON-serializable patch to be applied to metadata validation @@ -629,7 +625,7 @@ def patcher(doc, patch, patch_type): data = { "content-type": content_type, - "metadata": md_patch, + "metadata": metadata_patch, "specs": normalized_specs_patch, } @@ -640,7 +636,7 @@ def patcher(doc, patch, patch_type): ) ).json() - if md_patch is not None: + if metadata_patch is not None: if "metadata" in content: # Metadata was accepted and modified by the specs validator on the server side. # It is updated locally using the new version. @@ -649,7 +645,7 @@ def patcher(doc, patch, patch_type): # Metadata was accepted as it is by the server. # It is updated locally with the version submitted by the client. self._item["attributes"]["metadata"] = patcher( - dict(self.metadata), md_patch, content_type + dict(self.metadata), metadata_patch, content_type ) if specs_patch is not None: