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

Replicating usage docs results in '<' not supported between instances of 'VersionInfo' and 'tuple' #102

Closed
MrCreosote opened this issue Jul 16, 2018 · 8 comments

Comments

@MrCreosote
Copy link

I feel like I must be missing something, but when I follow the docs here, I get:

In [1]: import semver

In [2]: semver.__version__
Out[2]: '2.8.1'

In [3]: from semver import VersionInfo

In [4]: version_info = VersionInfo.parse("3.4.5-pre.2+build.4")

In [5]: version_info
Out[5]: VersionInfo(major=3, minor=4, patch=5, prerelease='pre.2', build='build.4')

In [6]: version_info > (1, 0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-d89d50dc6fc1> in <module>()
----> 1 version_info > (1, 0)

TypeError: '>' not supported between instances of 'VersionInfo' and 'tuple'

In [7]: version_info < (3, 5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-3076f0f266b0> in <module>()
----> 1 version_info < (3, 5)

TypeError: '<' not supported between instances of 'VersionInfo' and 'tuple'
@scls19fr
Copy link
Member

Good catch @MrCreosote

I'm personally not a big fan of comparison of
VersionInfo and tuple (and more generally VersionInfo and other type)

Moreover 3 numbers are required major, minor and patch

If we accept this kind of comparison we should also accept comparing VersionInfo and int

version_info >= 1

instead of

version_info >= VersionInfo(1, 0, 0)

Fixing doc will be easier but I let others contributors give their opinion.

@scls19fr
Copy link
Member

scls19fr commented Jul 17, 2018

Are you sure you are using latest version of python-semver?

In [1]: import semver

In [2]: semver.__version__
Out[2]: '2.8.1'

In [3]: from semver import VersionInfo

In [4]: version_info = VersionInfo.parse("3.4.5-pre.2+build.4")

In [5]: version_info
Out[5]: VersionInfo(major=3, minor=4, patch=5, prerelease='pre.2', build='build.4')

In [6]:  version_info > (1, 0)
Out[6]: False

In [7]: version_info > (1, 0, 0)
Out[7]: False

In [8]: version_info > VersionInfo(1, 0, 0)
Out[8]: True

My version is also buggy.... but in a different (worst?) way

We really need more tests!

@MrCreosote
Copy link
Author

I just pip'ed it today, and the version numbers line up, although we're getting different behavior... weird.

$ pip freeze | grep semver
semver==2.8.1
$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import semver

In [2]: semver.__version__
Out[2]: '2.8.1'

In [3]: from semver import VersionInfo

In [4]: version_info = VersionInfo.parse("3.4.5-pre.2+build.4")

In [5]: version_info > (1, 0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-d89d50dc6fc1> in <module>()
----> 1 version_info > (1, 0)

TypeError: '>' not supported between instances of 'VersionInfo' and 'tuple'

@MrCreosote
Copy link
Author

File md5 is the same as from the git default branch:

~/anaconda3$ md5sum lib/python3.6/site-packages/semver.py 
244842a555cd29363c451aad2593c3a4  lib/python3.6/site-packages/semver.py
~/localgit$ git clone https://github.com/k-bx/python-semver
Cloning into 'python-semver'...
*snip*
~/localgit$ md5sum python-semver/semver.py 
244842a555cd29363c451aad2593c3a4  python-semver/semver.py

@scls19fr
Copy link
Member

Which Python version? (Python 2.7.15) Which OS? (Windows 10)

@scls19fr
Copy link
Member

So it's a difference between Python 2 and Python 3

@scls19fr
Copy link
Member

An other odd behavior (with Python 2.7)

In [5]: version_info = VersionInfo.parse("3.4.5-pre.2+build.4")

In [6]: version_info > VersionInfo(1, 0, 0)
Out[6]: True

In [7]: version_info > '1.0.0'
Out[7]: False

@MrCreosote
Copy link
Author

Looks like you figured out I'm on 3.6.5. OS is Ubuntu 14.04.

Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
Flamefire pushed a commit to Flamefire/python-semver that referenced this issue May 29, 2019
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.

2 participants