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

Invalid PypiVersion #104

Open
ziadhany opened this issue Mar 1, 2023 · 2 comments
Open

Invalid PypiVersion #104

ziadhany opened this issue Mar 1, 2023 · 2 comments
Labels
2-next bug Something isn't working good first issue Good for newcomers

Comments

@ziadhany
Copy link
Contributor

ziadhany commented Mar 1, 2023

univers.versions.InvalidVersion: '10.0.2-1.1' is not a valid <class 'univers.versions.PypiVersion'>

See issues:

@alok1304
Copy link

alok1304 commented Jan 6, 2025

When i run in shell

>>> from univers.versions import PypiVersion
>>> v = PypiVersion("10.0.2-10.1.0")
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    v = PypiVersion("10.0.2-10.1.0")
  File "<attrs generated init univers.versions.Version>", line 7, in __init__
    self.__attrs_post_init__()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\lenovo\Documents\GitHub\web dev\univers\src\univers\versions.py", line 87, in __attrs_post_init__
    raise InvalidVersion(f"{self.string!r} is not a valid {self.__class__!r}")
univers.versions.InvalidVersion: '10.0.2-10.1.0' is not a valid <class 'univers.versions.PypiVersion'>

it is expected in output.
@pombredanne what we expect in output, also this is happened due to

    @classmethod
    def build_value(cls, string):
        """
        Return a packaging.version.LegacyVersion or packaging.version.Version
        """
        return packaging_version.Version(string)

@alok1304
Copy link

alok1304 commented Jan 6, 2025

@pombredanne
can i change this buld_value to

    @classmethod
    def build_value(cls, string):
        """
        Return a packaging.version.LegacyVersion or packaging.version.Version
        """
        try:
            return packaging_version.Version(string)
        except packaging_version.InvalidVersion:
            return False

basically it simply return false when package version is invalid without tracebacks..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-next bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants