refactor type check
This commit is contained in:
@@ -366,6 +366,11 @@ class AddOperation(PatchOperation):
|
|||||||
value = self.operation["value"]
|
value = self.operation["value"]
|
||||||
subobj, part = self.pointer.to_last(obj)
|
subobj, part = self.pointer.to_last(obj)
|
||||||
|
|
||||||
|
# type is already checked in to_last(), so we assert here
|
||||||
|
# for consistency
|
||||||
|
assert isinstance(subobj, list) or isinstance(subobj, dict), \
|
||||||
|
"invalid document type %s" (type(doc),)
|
||||||
|
|
||||||
if isinstance(subobj, list):
|
if isinstance(subobj, list):
|
||||||
|
|
||||||
if part == '-':
|
if part == '-':
|
||||||
@@ -385,10 +390,6 @@ class AddOperation(PatchOperation):
|
|||||||
else:
|
else:
|
||||||
subobj[part] = value
|
subobj[part] = value
|
||||||
|
|
||||||
else:
|
|
||||||
raise JsonPatchConflict("can't add to type '%s'"
|
|
||||||
"" % subobj.__class__.__name__)
|
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user