jmespath / jmespath/jmespath.py

Allow for subclassed types

Open
#158 5 comments 5 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.4k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

A little background first, in Ansible there is a `json_query` filter plugin which uses `jmespath` to query json. There is an issue open where users of that plugin get the following error:
```
JMESPathTypeError: In function contains(), invalid type for value: irb.1111, expected one of: ['array', 'string'], received: "unknown"
```
The comment that summarizes the issue is here https://github.com/ansible/ansible/issues/27299#issuecomment-366781707.

The error is caused by the fact that Ansible uses its own types for strings. One of the hacks we've come up with was:
```
jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ('AnsibleUnicode', 'AnsibleUnsafeText',)
```
which seems weird since I am pretty sure `REVERSE_TYPES_MAP` is not supposed to be public.

is there a proper way to do this? If not, is this something that would be considered to be added?

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.