stefankoegl / python-json-patch

Applying JSON Patches in Python
https://python-json-patch.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
434 stars 94 forks source link

FIX: TypeError when one forgot to put its operation in a list. #132

Closed JulienPalard closed 3 years ago

JulienPalard commented 3 years ago

Closes https://github.com/stefankoegl/python-json-patch/issues/131

>>> import jsonpatch
>>> jsonpatch.JsonPatch({'op': 'add', 'path': '/foo', 'value': 'bar'})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mdk/clones/stefankoegl/python-json-patch/jsonpatch.py", line 561, in __init__
    self._get_operation(op)
  File "/home/mdk/clones/stefankoegl/python-json-patch/jsonpatch.py", line 675, in _get_operation
    raise InvalidJsonPatch("Operation is expected to be a mapping, got a string.")
jsonpatch.InvalidJsonPatch: Operation is expected to be a mapping, got a string.
coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.05%) to 65.892% when pulling c9bfb91727690d6c7249b9250aba8942613f3f1c on JulienPalard:mdk/TypeError into 55d4816975350ea3f683814f4d025951ddfb1693 on stefankoegl:master.

JulienPalard commented 3 years ago

Not happy with my first message, I tried again:

>>> jsonpatch.JsonPatch({'op': 'add', 'path': '/foo', 'value': 'bar'})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mdk/clones/stefankoegl/python-json-patch/jsonpatch.py", line 563, in __init__
    raise InvalidJsonPatch("Document is expected to be sequence of "
jsonpatch.InvalidJsonPatch: Document is expected to be sequence of operations, got a sequence of strings.
stefankoegl commented 3 years ago

Thanks :)