-
Notifications
You must be signed in to change notification settings - Fork 96
TypeError when comparing VersionInfo to None #346
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
Comments
I see a test fail which is probably related:
|
Hi @cariad thanks for your report. Much appreciated and sorry for the late response (vacation). I haven't used semver together with dataclasses. What a nice way! However, I think, you miss something. 😉 Versions are ordered. According to the Python documentation, the dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False) As you can see, the Have you tried the following code? # imports the same as above
@dataclass(order=True)
class MyData2:
data: Optional[VersionInfo]
a = MyData2(data=VersionInfo(1))
b = MyData2(data=None)
assert a!= b With the above code you don't get any tracebacks. I hope I haven't overlooked something. Perhaps we could use this example in the documentation. Would that help? What do you think? |
How did you run the tests? When I run it against Python3.9, all tests pass. I did it with the command The test you've mentioned is a (doc)test from the documentation. The project is set up in a way that these tests are included too. In this specific case, this test is expected to fail because of the |
Using pytest on python 3.10. As @cariad is using Python 3.10 as well, maybe that's the reason?
If I interpret the error right, the problem is not the traceback itself, which is expected, but that
is expected, but
actually happens which shows similarity to the issue described by @cariad (and same Python version as well). The connection of the bugs is still a guess, but there are too much similarities. |
That could be the reason. I've just added support for Python 3.10 in #347. Wanna have a look? 🙂
Ahh, I see! Thanks for pointing it out. 👍 However, what I don't understand: if you look into the file >>> v > dict(major=1, unknown=42)
Traceback (most recent call last):
...
TypeError: ... got an unexpected keyword argument 'unknown' I remember, I've added the ellipsis (the three dots) after |
As the pypi package has a different directory structure, applying the PR as patch, doesn't work, so I tried using the branch itself and the build and test with it works. I didn't identify which exact commit of the 63 fixed it, but I doubt the the PR itself does fix it. -> A new release would solve the problem. |
Hey folks! I just built from the latest source and my original reproduction step now works. I'm happy to close this, knowing that an updated package will be released when it's good and ready. 😎 Thank you! |
Thanks for all! Actually I plan to release a new development version in the next days (depending on my schedule). Hope that's fine. 🙂 @cariad If you like, you can close the issue. Or you can leave it open and close it once the new dev version is released. |
Closing now! This issue isn't blocking me (I've forgotten how I worked around it, but everything's working so 🤷) so I'm not waiting on that dev release. 🚀 |
@tomschr Ah, you're amazing! Thank you! 😄 |
Situation
semver raises
TypeError
when comparingVersionInfo
toNone
.To Reproduce
Expected Behavior
I expect a comparison of
VersionInfo
toNone
to returnFalse
.For reference, this example with strings does work:
Environment
Additional context
The text was updated successfully, but these errors were encountered: