diff --git a/conda_smithy/variant_algebra.py b/conda_smithy/variant_algebra.py index 5602dd855..51f506b5f 100644 --- a/conda_smithy/variant_algebra.py +++ b/conda_smithy/variant_algebra.py @@ -123,7 +123,7 @@ def variant_add(v1: dict, v2: dict) -> Dict[str, Any]: # deal with __migrator: ordering if "__migrator" in v2: print(v2) - ordering = v2["__migrator"].get("ordering") + ordering = v2["__migrator"].get("ordering", {}) print(ordering) else: ordering = {} @@ -175,7 +175,7 @@ def variant_add(v1: dict, v2: dict) -> Dict[str, Any]: joint_variant = {} for k in joint: v_left, v_right = ensure_list(v1[k]), ensure_list(v2[k]) - joint_variant[k] = variant_key_add(k, v_left, v_right, ordering=ordering.get(k)) + joint_variant[k] = variant_key_add(k, v_left, v_right, ordering=ordering.get(k, None)) out = { **toolz.keyfilter(lambda k: k in left, v1), diff --git a/news/fix_variants.rst b/news/fix_variants.rst new file mode 100644 index 000000000..8691a81dd --- /dev/null +++ b/news/fix_variants.rst @@ -0,0 +1,24 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Don't make assumptions in ``conda_smithy/variant_algebra.py`` about the metadata + +**Security:** + +* + diff --git a/tests/test_variant_algebra.py b/tests/test_variant_algebra.py index 7f0c6aaab..aaf84bb2a 100644 --- a/tests/test_variant_algebra.py +++ b/tests/test_variant_algebra.py @@ -96,6 +96,36 @@ def test_ordering(): # raise Exception() +def test_no_ordering(): + start = parse_variant( + dedent( + """\ + xyz: + - 1 + """ + ) + ) + + mig_compiler = parse_variant( + dedent( + """\ + __migrator: + kind: + version + migration_no: + 1 + xyz: + - 2 + """ + ) + ) + + res = variant_add(start, mig_compiler) + assert res["xyz"] == ["2"] + print(res) + # raise Exception() + + def test_ordering_downgrade(): start = parse_variant( dedent(