Feature: Use Jinja's new NativeEnvironment to get native types instead of strings!
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
It's really hard to deal with magically converting from Jinja strings back into native python types. Let's just skip the conversion and use native python types.
How you ask? Jinja has merged a pretty cool PR: pallets/jinja#708
Here's a quote from the new doc:
The default
jinja2.Environmentrenders templates to strings. WithNativeEnvironment, rendering a template produces a native Python type.
This consists of three basic parts: NativeCodeGenerator, NativeTemplate, and NativeEnvironment. Check out the code. This will land in Jinja 2.10.
This comes from an ansible PR by @jctanner: ansible/ansible#23943
I suspect that using NativeEnvironment would resolve (or make a big dent in) these:
- #1231 Preserve type in ActionChain published vars
- #2976 Complex types (other than string) in dynamic config
- #3515 allow explicit casting of Jinja types
- StackStorm-Exchange/stackstorm-ansible#14 Parsing directives !JSON, !AST, and !INT that convert strings (like from Jinja) to python types.
- Plus, maybe it would be one component in allowing complex (ie non-string) data types in the datastore.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Jinja's NativeEnvironment proposal and the existing string-to-native conversion paths implicated by issues #1231, #2976, and #3515. Determine which StackStorm rendering and datastore flows would need native types, then define tests covering those flows and verify that the listed conversion problems are addressed without breaking existing string rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100