Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
kenodegard and JeanChristopheMorinPerso authored Nov 2, 2023
1 parent 2f08ee6 commit 0153f01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ def filter_combined_spec_to_used_keys(combined_spec, specs):

# TODO: act here?
combined_spec = explode_variants(combined_spec)
seen_keys = (
set()
) # seen_keys makes sure that a setting from a lower-priority spec doesn't clobber the same setting that has been redefined in a higher-priority spec.
# seen_keys makes sure that a setting from a lower-priority spec doesn't clobber
# the same setting that has been redefined in a higher-priority spec.
seen_keys = set()
# The specs are checked from high to low priority order.
for source, source_specs in reversed(specs.items()):
for k, vs in source_specs.items():
Expand Down
26 changes: 13 additions & 13 deletions tests/test_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,14 @@ def test_variant_subkeys_retained():
@pytest.mark.parametrize(
"internal_defaults, low_prio_config, high_prio_config, expected",
[
(
pytest.param(
{"pkg_1": "1.0"},
{"pkg_1": "1.1"},
{"pkg_1": ["1.1", "1.2"], "pkg_2": ["1.1"]},
[{"pkg_1": "1.1", "pkg_2": "1.1"}, {"pkg_1": "1.2", "pkg_2": "1.1"}],
id="basic",
),
(
pytest.param(
{"pkg_1": "1.0"},
{"pkg_1": "1.1"},
{
Expand All @@ -681,22 +682,21 @@ def test_variant_subkeys_retained():
{"pkg_1": "1.1", "pkg_2": "1.1", "zip_keys": [["pkg_1", "pkg_2"]]},
{"pkg_1": "1.2", "pkg_2": "1.2", "zip_keys": [["pkg_1", "pkg_2"]]},
],
id="zip_keys",
),
],
)
def test_zip_key_filtering(
internal_defaults, low_prio_config, high_prio_config, expected
):
from collections import OrderedDict

combined_spec = low_prio_config.copy()
combined_spec.update(high_prio_config)
specs = OrderedDict(
[
("internal_defaults", internal_defaults),
("low_prio_config", low_prio_config),
("high_prio_config", high_prio_config),
]
)
combined_spec = {
**low_prio_config,
**high_prio_config,
}
specs = {
"internal_defaults": internal_defaults,
"low_prio_config": low_prio_config,
"high_prio_config": high_prio_config,
}

assert filter_combined_spec_to_used_keys(combined_spec, specs=specs) == expected

0 comments on commit 0153f01

Please sign in to comment.