Add support for 'arraylike' objects as JSON arrays#317
Open
calgray wants to merge 4 commits intojmespath:developfrom
Open
Add support for 'arraylike' objects as JSON arrays#317calgray wants to merge 4 commits intojmespath:developfrom
calgray wants to merge 4 commits intojmespath:developfrom
Conversation
Dobatymo
reviewed
Dec 5, 2024
| @@ -1,5 +1,6 @@ | |||
| import math | |||
| import json | |||
| from typing import Sequence | |||
There was a problem hiding this comment.
this is deprecated and should be
Suggested change
| from typing import Sequence | |
| from collections.abc import Sequence |
I think
There was a problem hiding this comment.
That's only available in Python 3.9+ but the project still declares support for 3.7 and 3.8
There was a problem hiding this comment.
it's available in older versions. only subscripting like Sequence[int] (which is not used) is only available in newer versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JMESPath.py is limited in that only the
dictandlistderived containers returned by the built-injsonlibrary are supported in the object hierarchy due to the use ofisinstance. A very notable arraylike instance that does not derive directly from these containers is anumpy.ndarraywhich can be deserialized using the JSON-likemsgpacklibrary withmsgpack_numpy.This changeset aims to add support for arraylike (
list,tupleandnumpy.ndarray) containers in place of parsed JSON arrays and without adding any dependency on thenumpylibrary. This is done using the documented numpy array interface protocol of which many more arraylike libraries adhere to such asxarray,dask,astropyandcupy.(
pandas.Seriesis also arraylike but limited to 1D as multidimensional Series isn't an intended use case and has slicing issues)