Skip to content

Commit

Permalink
Remove unused import introduced by rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Jun 4, 2024
1 parent 315cdc2 commit 471c097
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tiled/_tests/test_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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},
],
Expand Down
26 changes: 11 additions & 15 deletions tiled/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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).
Expand All @@ -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
Expand Down Expand Up @@ -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,
}

Expand All @@ -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.
Expand All @@ -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:
Expand Down

0 comments on commit 471c097

Please sign in to comment.