Skip to content

Fallback sorting on labels#132

Open
mgorny wants to merge 18 commits intomainfrom
sort-labels
Open

Fallback sorting on labels#132
mgorny wants to merge 18 commits intomainfrom
sort-labels

Conversation

@mgorny
Copy link
Copy Markdown
Collaborator

@mgorny mgorny commented Apr 10, 2026

Effort to add the fallback sort on variant label. After much testing, I've figured out that the only sane way to do this without having to change all the API is to add label to VariantDescription. For now, we're not verifying it yet, since there's still tons of call sites to update.

@mgorny mgorny requested a review from DEKHTIARJonathan April 10, 2026 16:17
mgorny added 7 commits April 10, 2026 20:02
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Note that we do not guarantee passing variant label to the function yet.

Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
mgorny added 10 commits April 13, 2026 17:43
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny mgorny marked this pull request as ready for review April 14, 2026 13:53
@mgorny mgorny requested review from konstin and rgommers April 14, 2026 13:53
@mgorny
Copy link
Copy Markdown
Collaborator Author

mgorny commented Apr 14, 2026

Okay, this is bigger than I initially planned but I think it's better to make it more future-proof.

The key changes are:

  1. VariantDescription now carries the label in addition to variant properties. If it's not provided explicitly, we default to self.hexdigest or null.
  2. The separate label argument to the API functions is now deprecated, but still supported — in which case it overrides the label found in VariantDescription. However, for future code we expect users to set label on VariantDescription.
  3. Consequently, the get_variant_label() helper is now deprecated in favor of VariantDescription.label.
  4. The sort algorithm is updated to take variant label as the final sort key, per the PEP. I've added extra tests for that.
  5. I've updated all the tests to explicitly pass label= when constructing non-null VariantDescription. This is not technically necessary now; I've temporarily made that a requirement to make sure I didn't miss any call site. That said, I suppose the tests are more future-proof that way, in case we ever make labels required.
  6. In data types that carry the label explicitly (dicts), we preserve the original format but aim to sync the label between the keys and VariantDescriptions.

Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny mgorny changed the title [WIP] Fallback sorting on labels Fallback sorting on labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant