Skip to content

Commit c4f9486

Browse files
committed
api: Simplify get_variants_by_priority() to use vdesc labels
Signed-off-by: Michał Górny <mgorny@quansight.com>
1 parent 75d9ab8 commit c4f9486

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

variantlib/api.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def get_variants_by_priority(
5858
if not isinstance(variants_json, VariantsJson):
5959
variants_json = VariantsJson(variants_json)
6060

61+
assert all(vdesc.label == label for label, vdesc in variants_json.variants.items())
62+
6163
venv_python_executable = (
6264
venv_python_executable
6365
if venv_python_executable is None
@@ -77,14 +79,9 @@ def get_variants_by_priority(
7779
)
7880

7981
config = VariantConfiguration.get_config()
80-
label_map = {
81-
vdesc.hexdigest: label for label, vdesc in variants_json.variants.items()
82-
}
83-
# handle the implicit null variant
84-
label_map.setdefault(VariantDescription([]).hexdigest, NULL_VARIANT_LABEL)
8582

8683
return [
87-
label_map[vdesc.hexdigest]
84+
vdesc.label
8885
for vdesc in sort_and_filter_supported_variants(
8986
list(variants_json.variants.values()),
9087
supported_vprops,

0 commit comments

Comments
 (0)