PEP8 and support for `env:VAR_NAME`
Split it into two commits because the new feature isn't part of the JSON Pointer or JSON Reference standards; so you can easily cherrypick.
Coverage increased (+0.05%) to 91.909% when pulling e481a30213cffcbfa611a5b55672586dc6c330e3 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.
Coverage decreased (-3.1%) to 88.715% when pulling 71237ffea8e19f429ef5e18edcd94e2ae2c246d9 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.
Coverage decreased (-3.1%) to 88.715% when pulling 27f04358e459107e8bc21fcee947710fd2b25856 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.
Coverage decreased (-3.8%) to 88.037% when pulling 1285f9126b5b2aa87c2c2a38349e241e0fd22830 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.
Coverage decreased (-4.3%) to 87.234% when pulling e30aab61bbc3b1261a55d2fb64f56793ec09c242 on offscale:master into 066132e527f8115f75bcadfd0eca12f8973a6309 on gazpachoking:master.
Add tests; coverage decreases
LOL: that didn't go as expected!
@gazpachoking Decided to update this after 3 years…
I think I took care of the PEP parts of this PR when I added black to the pre-commit hooks. As for the ENV part, I'm not sure directly supporting that is appropriate. I think using a custom loader to handle those URIs would work though, without any modifications to the core?
@gazpachoking Can you describe what that would look like? - Would the ENV: syntax still work? - Are you thinking some URI style syntax with a fake device/mount like file://ENV:VAR_NAME?
@gazpachoking Can you describe what that would look like? - Would the
ENV:syntax still work? - Are you thinking some URI style syntax with a fake device/mount likefile://ENV:VAR_NAME?
Here's a simple example of what I mean:
import os
import jsonref
json = {
"a": {"$ref": "env:MYENV"}
}
def loader(uri):
if uri.startswith("env:"):
return os.environ[uri[4:]]
# If you want to fall back to the default loader:
return jsonref.jsonloader(uri)
print(jsonref.replace_refs(json, loader=loader))
I added that example to the docs for upcoming release. Going to close this out now. Feel free to open other issues or PRs if you've got any!