Skip to content

StableKeywordsCheck: detect packages using stable keywords#769

Open
falbrechtskirchinger wants to merge 1 commit intopkgcore:masterfrom
falbrechtskirchinger:stablekeywords
Open

StableKeywordsCheck: detect packages using stable keywords#769
falbrechtskirchinger wants to merge 1 commit intopkgcore:masterfrom
falbrechtskirchinger:stablekeywords

Conversation

@falbrechtskirchinger
Copy link

Add an optional check to scan for packages using stable keywords. This is useful for overlays like ::guru, which require that all packages be keyworded unstable.

The implementation is based on UnstableOnlyCheck, though strictly copying the restrictions mechanism results in O(N * M), where a simple set intersection could be O(N).
The severity was chosen based on the language in the regulations (rule 4): "Stable keywords must not be used." (emphasis mine)

Tests

  • Added a new repo, as this check conflicts with other test cases using stable keywords.
  • Added test ebuilds to exercise both positive and negative paths.
  • Added expected.json and fix.patch.

Add an optional check to scan for packages using stable keywords. This
is useful for overlays like ::guru, which require that all packages be
keyworded unstable.

Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Copy link
Member

@thesamesam thesamesam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks reasonable to me.

Copy link
Member

@arthurzam arthurzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please handle those comments. Sorry for long delay


_source = sources.PackageRepoSource
required_addons = (addons.StableArchesAddon,)
known_results = frozenset([StableKeywords])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
known_results = frozenset([StableKeywords])
known_results = frozenset({StableKeywords})

Comment on lines +11 to +12
class StableKeywords(results.PackageResult, results.Error):
"""Package uses stable keywords."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a good result name and description - what does it even mean? A developer that gets such error won't understand it's reason.


def __init__(self, *args, stable_arches_addon=None):
super().__init__(*args)
self.arches = {x.strip().lstrip("~") for x in self.options.stable_arches}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.arches = {x.strip().lstrip("~") for x in self.options.stable_arches}
self.arches = frozenset({x.strip().lstrip("~") for x in self.options.stable_arches})

I like immutability

Copy link
Contributor

@ferringb ferringb Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request to make this immutable may sound pedantic, but I fixed an issue the other day where code was incorrectly mutating a Result object, so that pattern we maintain, exists for a valid reason. It's not python standard, but the defensive approach has prevented a surprisingly large amount of fuckups.

TL;DR: please make it immutable. Frankly a tuple is fine rather than a frozenset also, but whatever convention is, go with that.

class StableKeywordsCheck(OptionalCheck):
"""Scan for packages using stable keywords."""

_source = sources.PackageRepoSource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use here Repo scope and not just Package scope like most other scans? It would be much simpler to handle, group, ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be package scope; the only results it generates are package scope already.


def __init__(self, *args, stable_arches_addon=None):
super().__init__(*args)
self.arches = {x.strip().lstrip("~") for x in self.options.stable_arches}
Copy link
Contributor

@ferringb ferringb Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request to make this immutable may sound pedantic, but I fixed an issue the other day where code was incorrectly mutating a Result object, so that pattern we maintain, exists for a valid reason. It's not python standard, but the defensive approach has prevented a surprisingly large amount of fuckups.

TL;DR: please make it immutable. Frankly a tuple is fine rather than a frozenset also, but whatever convention is, go with that.

# collapse reports by sets of arches
for arches, pkgs in arches_pkgs.items():
versions = (pkg.fullver for pkg in sorted(pkgs))
yield StableKeywords(versions, sort_keywords(arches), pkg=pkgs[0])
Copy link
Contributor

@ferringb ferringb Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move sort_keywords into the __init__ of StableKeywords. the sorting is an aspect of that result's presentation- somethiing it's responsible for.

Encapsulation wise, it shouldn't expect that creators of the instance know to sort that value. Your code does, other code absolutely won't. :)

class StableKeywordsCheck(OptionalCheck):
"""Scan for packages using stable keywords."""

_source = sources.PackageRepoSource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be package scope; the only results it generates are package scope already.

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.

4 participants

Comments