diff --git a/snakemake/__init__.py b/snakemake/__init__.py index 95d16e43a..c2667f0a8 100644 --- a/snakemake/__init__.py +++ b/snakemake/__init__.py @@ -970,8 +970,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 diff --git a/tests/testapi.py b/tests/testapi.py index 6be11228d..925a21534 100644 --- a/tests/testapi.py +++ b/tests/testapi.py @@ -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'}})