Tilde requirements vs PEP 440 compatible release
See original GitHub issuehttps://python-poetry.org/docs/versions/#tilde-requirements https://www.python.org/dev/peps/pep-0440/#compatible-release
PEP 440 describes the use of ~
in version specifiers. Imprecisely, it treats the version given as the minimum version, and treats the final segment of the version specifier as a *
.
This is notably different than ^
in Poetry and other languages’ package managers (caret requirements are not in PEP440), which treats the version given as the minimum version, and treats all segments after the first as a *
.
I expect that for many people, if they are wishing to use only PEP440 version specifiers for some reason, that compatible releases might be just the thing to use.
Unfortunately, it appears that Poetry either has a documentation bug, or has a behavior with this version specifier that is incompatible with PEP 440. The Poetry documentation for tilde requirements gives three examples, two of which are not compatible with PEP 440 compatible release. Compare what PEP 440 says to what the Poetry docs say, to what the docs should say if using the same format to match the meaning of PEP 440.
requirement | PEP 440 says | Poetry docs say | Poetry docs should say |
---|---|---|---|
~1.2.3 |
>=1.2.3,1.2.* |
>=1.2.3 <1.3.0 |
>=1.2.3 <1.3.0 |
~1.2 |
>=1.2,1.* |
>=1.2.0 <1.3.0 |
>=1.2.3 <2 |
~1 |
invalid | >=1.0.0 <2.0.0 |
? |
For many cases, including my own, I expect that people will want a version specifier that is like PEP 440’s ~1.2
meaning, but to get (almost) that with Poetry they have to use ~1
, which is an explicitly invalid specifier under PEP 440. I think that Poetry should match PEP 440’s version specifier’s meaning.
Poetry might prefer to assign a valid meaning to the ~1
version, although I think I’d prefer to follow PEP 440 there as well and throw an error, but having valid PEP 440 specifiers do (or document) something other than what PEP 440 instructs seems very unwise.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
I see maybe same/or other issue with poetry==1.2.0a2:
@dimbleby: You are right, although there was a documentation issue brought up that appears to be rectified now.
@pbhuss: Thank you for your work on that comment, very effectively demonstrating my confusion. The documentation issue you pointed out in your comment appears to be fixed up.
I could appreciate some additional language clarifying that is is not the same as PEP 440’s
~=
operator, and that~=
does work. Still, my OP was ultimately invalid and confused.