Skip to content

Throw ValueError when instantiating a VersionRange from None type #113

Description

@keshav-space

Currently, we're not correctly handling the cases where the input string is None

from univers.version_range import VersionRange 
>>> VersionRange.from_string(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../univers/src/univers/version_range.py", line 102, in from_string
    vers = remove_spaces(vers)
  File "../univers/src/univers/utils.py", line 9, in remove_spaces
    return "".join(string.split())
AttributeError: 'NoneType' object has no attribute 'split'

We should raise ValueError similar to what we do with empty string.

from univers.version_range import VersionRange 
>>> VersionRange.from_string("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../univers/src/univers/version_range.py", line 115, in from_string
    raise ValueError(f"{vers!r} must start with the 'vers:' URI scheme.")
ValueError: '' must start with the 'vers:' URI scheme.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions