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

fix: remove raise that limits using --config with dicts #1341

Merged
merged 5 commits into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions snakemake/__init__.py
Expand Up @@ -958,8 +958,6 @@ def unparse_config(config):
raise ValueError("config is not a dict")
items = []
for key, value in config.items():
if isinstance(value, dict):
raise ValueError("config may only be a flat dict")
encoded = "'{}'".format(value) if isinstance(value, str) else value
items.append("{}={}".format(key, encoded))
return items
Expand Down
19 changes: 19 additions & 0 deletions tests/testapi.py
Expand Up @@ -57,3 +57,22 @@ async def main():
async_run(main())
else:
asyncio.run(main())


def test_dicts_in_config():
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, "Snakefile")
with open(path, "w") as f:
print(
dedent(
"""
rule:
output: 'result.txt'
run:
with open(output[0], 'w') as f:
print("hello, this option " + config["this_option"] + "; this test dictionary " + config["test"]["this_dict"], file=f)
"""
),
file=f,
)
snakemake(path, workdir=tmpdir, config={"this_option": "does_not_break", "test": {'this_dict':'shoult_not_either'}})