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

Throw ValueError when instantiating a VersionRange from None type #113

Closed
keshav-space opened this issue Aug 29, 2023 · 0 comments · Fixed by #115
Closed

Throw ValueError when instantiating a VersionRange from None type #113

keshav-space opened this issue Aug 29, 2023 · 0 comments · Fixed by #115

Comments

@keshav-space
Copy link
Member

keshav-space commented Aug 29, 2023

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.
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 a pull request may close this issue.

1 participant