Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Jsonnet as a config format #19

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add jsonnet to parameterized format test, fix usage of self in static…
…method
Ido Weiss committed Oct 3, 2022
commit 09bcbb2e572fbe1163144bcfd60e56340789df7f
4 changes: 2 additions & 2 deletions pyrallis/parsers/config_parsers.py
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ def save_config(d, stream=None, **kwargs):
return json.dump(d, stream, **kwargs)


class JSONNETParser(Parser):
class JSONNETParser(JSONParser):

@staticmethod
def parse_string(s):
@@ -84,7 +84,7 @@ def parse_string(s):
@staticmethod
def load_config(stream):
s = stream.read() # Jsonnet doesn't provide stream API
return self.parse_string(s)
return JSONNETParser.parse_string(s)


class TOMLParser(Parser):
2 changes: 1 addition & 1 deletion tests/test_decoding.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ class SomeClass:
assert pyrallis.decode(SomeClass, pyrallis.encode(b)) == b


@parametrize('config_type', ['', 'yaml', 'json', 'toml'])
@parametrize('config_type', ['', 'yaml', 'json', 'jsonnet', 'toml'])
def test_dump_load(simple_attribute, config_type, tmp_path):
some_type, _, expected_value = simple_attribute