Closed
Description
Situation
semver raises TypeError
when comparing VersionInfo
to None
.
To Reproduce
from dataclasses import dataclass
from typing import Optional
from semver import VersionInfo
@dataclass
class MyData:
data: Optional[VersionInfo]
a = MyData(data=VersionInfo(1))
b = MyData(data=None)
assert a != b
Traceback (most recent call last):
File "/home/cariad/startifact/version.py", line 15, in <module>
assert a != b
File "<string>", line 4, in __eq__
File "/home/cariad/startifact/.venv/lib/python3.10/site-packages/semver.py", line 200, in wrapper
raise TypeError(
TypeError: other type <class 'NoneType'> must be in (<class 'semver.VersionInfo'>, <class 'dict'>, <class 'tuple'>, <class 'list'>, <class 'str'>, <class 'bytes'>)
Expected Behavior
I expect a comparison of VersionInfo
to None
to return False
.
For reference, this example with strings does work:
from dataclasses import dataclass
from typing import Optional
@dataclass
class MyData:
data: Optional[str]
a = MyData(data="foo")
b = MyData(data=None)
assert a != b
Environment
- OS: Linux
- Python version: 3.10
- Version of semver library: 2.13.0
Additional context
- I ❤️ semver -- thanks for all your work!
- I'm happy to work on a pull request. Let me know?
Metadata
Metadata
Assignees
Labels
Error, flaw or fault to produce incorrect or unexpected resultsError, flaw or fault to produce incorrect or unexpected results