Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VersionWithSource type to py-rattler #304

Merged

Conversation

Wackyator
Copy link
Contributor

No description provided.

@wolfv
Copy link
Contributor

wolfv commented Aug 30, 2023

I think if we add a VersionBase class in Python we can get away with implementing the forwarding functions for a few things only once.

E.g.

class VersionBase:
    @property
    def epoch(self) -> Optional[str]:
        """
        Gets the epoch of the version or `None` if the epoch was not defined.

        Examples
        --------
        >>> v = Version('2!1.0')
        >>> v.epoch
        2
        """
        return self._version.epoch()

    @property
    def has_local(self) -> bool:
        """
        Returns true if this version has a local segment defined.
        The local part of a version is the part behind the (optional) `+`.

        Examples
        --------
        >>> v = Version('1.0+3.2-alpha0')
        >>> v.has_local
        True
        >>> v2 = Version('1.0')
        >>> v2.has_local
        False
        """
        return self._version.has_local()

If both, Version and VersionWithSource call the inner type _inner you can align the two, and inherit with both from VersionBase. That should remove some (trivial) duplication.

@baszalmstra
Copy link
Collaborator

Instead of having a VersionBase, wouldnt it be possible to have a Version and a VersionWithSource that derives from Version and adds a source string? Thats essentially what it is.

Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

I like this approach but it raises the question: do we even need the PyVersionWithSource?

py-rattler/src/version/with_source.rs Outdated Show resolved Hide resolved
@baszalmstra baszalmstra merged commit f9b20fe into conda:main Sep 7, 2023
8 checks passed
@Wackyator Wackyator deleted the feat/py-rattler-version-with-source branch September 12, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants