Skip to content

Commit e90dba0

Browse files
committed
Add arguments description to docstrings.
1 parent 13a252d commit e90dba0

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

jsonpatch.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,42 @@ class JsonPatchConflict(JsonPatchException):
6464
def apply_patch(doc, patch, in_place=False):
6565
"""Apply list of patches to specified json document.
6666
67+
:param doc: Document object.
68+
:type doc: dict
69+
70+
:param patch: JSON patch as list of dicts.
71+
:type patch: list
72+
73+
:param in_place: While :const:`True` patch will modify target document.
74+
By default patch will be applied to document copy.
75+
:type in_place: bool
76+
77+
:return: Patched document object.
78+
:rtype: dict
79+
6780
>>> doc = {'foo': 'bar'}
6881
>>> other = apply_patch(doc, [{'add': '/baz', 'value': 'qux'}])
6982
>>> doc is not other
7083
True
7184
>>> other
7285
{'foo': 'bar', 'baz': 'qux'}
86+
>>> apply_patch(doc, [{'add': '/baz', 'value': 'qux'}], in_place=True)
87+
{'foo': 'bar', 'baz': 'qux'}
88+
>>> doc == other
89+
True
7390
"""
7491

7592
patch = JsonPatch(patch)
7693
return patch.apply(doc, in_place)
7794

7895
def make_patch(src, dst):
79-
"""Generates patch by comparing of two objects.
96+
"""Generates patch by comparing of two document objects.
97+
98+
:param src: Data source document object.
99+
:type src: dict
100+
101+
:param dst: Data source document object.
102+
:type dst: dict
80103
81104
>>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
82105
>>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}

0 commit comments

Comments
 (0)