Skip to content

Refactor Ecosystem helper interface #3745

@michaelkedar

Description

@michaelkedar

The Ecosystem class is confusing to use:

  • It has abstract methods sort_key and enumerate_versions that are not required to be implemented (but must be overwritten with a function that raises a NotImplementedError)
  • To check whether these are implemented, the respective (and poorly named) supports_comparing and supports_ordering properties must be manually implemented & checked.

In my opinion, it would be better to have a few interfaces:

  • Ecosystem(), a replacement for the current OrderingUnsupportedEcosystem, with whatever base things are needed
  • ComparableEcosystem(Ecosystem, ABC), which are ecosystems which we can create orderings of version strings (i.e. which implement sort_key)
  • EnumerableEcosystem(ComparableEcosystem), which are ecosystems which we can find all concrete versions for (i.e. which implement enumerate_versions)

With this, we could replace the supports_x properties with isinstance calls. It also would make reusing logic for ecosystems which use the same versioning scheme but have different enumerations (e.g. APK/RPM ecosystems #3431)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogImportant but currently unprioritizedcleanupCode hygiene and cleanup

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions