python-jsonpath 1.3.0__tar.gz → 1.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/PKG-INFO +3 -1
  2. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/README.md +2 -0
  3. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/__about__.py +1 -1
  4. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/filter.py +1 -1
  5. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/arguments.py +2 -1
  6. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/patch.py +8 -8
  7. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/pointer.py +3 -0
  8. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/.gitignore +0 -0
  9. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/LICENSE.txt +0 -0
  10. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/__init__.py +0 -0
  11. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/__main__.py +0 -0
  12. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/_data.py +0 -0
  13. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/cli.py +0 -0
  14. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/env.py +0 -0
  15. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/exceptions.py +0 -0
  16. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/fluent_api.py +0 -0
  17. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/__init__.py +0 -0
  18. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/count.py +0 -0
  19. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/filter_function.py +0 -0
  20. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/is_instance.py +0 -0
  21. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/keys.py +0 -0
  22. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/length.py +0 -0
  23. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/match.py +0 -0
  24. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/search.py +0 -0
  25. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/typeof.py +0 -0
  26. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/function_extensions/value.py +0 -0
  27. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/lex.py +0 -0
  28. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/match.py +0 -0
  29. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/parse.py +0 -0
  30. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/path.py +0 -0
  31. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/py.typed +0 -0
  32. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/selectors.py +0 -0
  33. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/serialize.py +0 -0
  34. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/stream.py +0 -0
  35. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/jsonpath/token.py +0 -0
  36. {python_jsonpath-1.3.0 → python_jsonpath-1.3.1}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-jsonpath
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: JSONPath, JSON Pointer and JSON Patch for Python.
5
5
  Project-URL: Documentation, https://jg-rp.github.io/python-jsonpath/
6
6
  Project-URL: Issues, https://github.com/jg-rp/python-jsonpath/issues
@@ -97,6 +97,8 @@ conda install -c conda-forge python-jsonpath
97
97
 
98
98
  - [JSON P3](https://github.com/jg-rp/json-p3) - RFC 9535 implemented in TypeScript. JSON P3 does not include all the non-standard features of Python JSONPath, but does define some optional [extra syntax](https://jg-rp.github.io/json-p3/guides/jsonpath-extra).
99
99
 
100
+ - [Ruby JSON P3](https://github.com/jg-rp/ruby-json-p3) - RFC 9535, RFC 6901 and RFC 6902 implemented in Ruby.
101
+
100
102
  ## Examples
101
103
 
102
104
  ### JSONPath
@@ -72,6 +72,8 @@ conda install -c conda-forge python-jsonpath
72
72
 
73
73
  - [JSON P3](https://github.com/jg-rp/json-p3) - RFC 9535 implemented in TypeScript. JSON P3 does not include all the non-standard features of Python JSONPath, but does define some optional [extra syntax](https://jg-rp.github.io/json-p3/guides/jsonpath-extra).
74
74
 
75
+ - [Ruby JSON P3](https://github.com/jg-rp/ruby-json-p3) - RFC 9535, RFC 6901 and RFC 6902 implemented in Ruby.
76
+
75
77
  ## Examples
76
78
 
77
79
  ### JSONPath
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present James Prior <jamesgr.prior@gmail.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "1.3.0"
4
+ __version__ = "1.3.1"
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
30
30
  from .path import JSONPath
31
31
  from .selectors import FilterContext
32
32
 
33
- # ruff: noqa: D102
33
+ # ruff: noqa: D102, PLW1641
34
34
 
35
35
 
36
36
  class FilterExpression(ABC):
@@ -1,4 +1,5 @@
1
1
  """Class-based function extension base."""
2
+
2
3
  import inspect
3
4
  from typing import TYPE_CHECKING
4
5
  from typing import Any
@@ -26,7 +27,7 @@ def validate(
26
27
  params = list(inspect.signature(func).parameters.values())
27
28
 
28
29
  # Keyword only params are not supported
29
- if len([p for p in params if p.kind in (p.KEYWORD_ONLY, p.VAR_KEYWORD)]):
30
+ if [p for p in params if p.kind in (p.KEYWORD_ONLY, p.VAR_KEYWORD)]:
30
31
  raise JSONPathTypeError(
31
32
  f"function {token.value!r} requires keyword arguments",
32
33
  token=token,
@@ -74,7 +74,7 @@ class OpAdd(Op):
74
74
  else:
75
75
  parent.insert(int(target), self.value)
76
76
  elif isinstance(parent, MutableMapping):
77
- parent[target] = self.value
77
+ parent[str(target)] = self.value
78
78
  else:
79
79
  raise JSONPatchError(
80
80
  f"unexpected operation on {parent.__class__.__name__!r}"
@@ -124,7 +124,7 @@ class OpAddAp(OpAdd):
124
124
  """A non-standard add operation that appends to arrays/lists .
125
125
 
126
126
  This is like _OpAdd_, but assumes an index of "-" if the path can not
127
- be resolved.
127
+ be resolved rather than raising a JSONPatchError.
128
128
 
129
129
  **New in version 1.2.0**
130
130
  """
@@ -183,7 +183,7 @@ class OpRemove(Op):
183
183
  elif isinstance(parent, MutableMapping):
184
184
  if obj is UNDEFINED:
185
185
  raise JSONPatchError("can't remove nonexistent property")
186
- del parent[self.path.parts[-1]]
186
+ del parent[str(self.path.parts[-1])]
187
187
  else:
188
188
  raise JSONPatchError(
189
189
  f"unexpected operation on {parent.__class__.__name__!r}"
@@ -221,7 +221,7 @@ class OpReplace(Op):
221
221
  elif isinstance(parent, MutableMapping):
222
222
  if obj is UNDEFINED:
223
223
  raise JSONPatchError("can't replace nonexistent property")
224
- parent[self.path.parts[-1]] = self.value
224
+ parent[str(self.path.parts[-1])] = self.value
225
225
  else:
226
226
  raise JSONPatchError(
227
227
  f"unexpected operation on {parent.__class__.__name__!r}"
@@ -259,7 +259,7 @@ class OpMove(Op):
259
259
  if isinstance(source_parent, MutableSequence):
260
260
  del source_parent[int(self.source.parts[-1])]
261
261
  if isinstance(source_parent, MutableMapping):
262
- del source_parent[self.source.parts[-1]]
262
+ del source_parent[str(self.source.parts[-1])]
263
263
 
264
264
  dest_parent, _ = self.dest.resolve_parent(data)
265
265
 
@@ -270,7 +270,7 @@ class OpMove(Op):
270
270
  if isinstance(dest_parent, MutableSequence):
271
271
  dest_parent.insert(int(self.dest.parts[-1]), source_obj)
272
272
  elif isinstance(dest_parent, MutableMapping):
273
- dest_parent[self.dest.parts[-1]] = source_obj
273
+ dest_parent[str(self.dest.parts[-1])] = source_obj
274
274
  else:
275
275
  raise JSONPatchError(
276
276
  f"unexpected operation on {dest_parent.__class__.__name__!r}"
@@ -312,7 +312,7 @@ class OpCopy(Op):
312
312
  if isinstance(dest_parent, MutableSequence):
313
313
  dest_parent.insert(int(self.dest.parts[-1]), copy.deepcopy(source_obj))
314
314
  elif isinstance(dest_parent, MutableMapping):
315
- dest_parent[self.dest.parts[-1]] = copy.deepcopy(source_obj)
315
+ dest_parent[str(self.dest.parts[-1])] = copy.deepcopy(source_obj)
316
316
  else:
317
317
  raise JSONPatchError(
318
318
  f"unexpected operation on {dest_parent.__class__.__name__!r}"
@@ -419,7 +419,7 @@ class JSONPatch:
419
419
  value=self._op_value(operation, "value", "addne", i),
420
420
  )
421
421
  elif op == "addap":
422
- self.addne(
422
+ self.addap(
423
423
  path=self._op_pointer(operation, "path", "addap", i),
424
424
  value=self._op_value(operation, "value", "addap", i),
425
425
  )
@@ -485,6 +485,9 @@ class RelativeJSONPointer:
485
485
  def __eq__(self, __value: object) -> bool:
486
486
  return isinstance(__value, RelativeJSONPointer) and str(self) == str(__value)
487
487
 
488
+ def __hash__(self) -> int:
489
+ return hash((self.origin, self.index, self.pointer))
490
+
488
491
  def _parse(
489
492
  self,
490
493
  rel: str,