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

Resolve invalid python version constraint #154

Conversation

pbzweihander
Copy link

@pbzweihander pbzweihander commented Apr 2, 2021

Resolves: python-poetry#

  • Added tests for changed code.
  • Updated documentation for changed code.

backports.functools_lru_cache has following dependency in setup.cfg (https://github.com/jaraco/backports.functools_lru_cache/blob/74120920aa77047323b7ca25533f57bdae4ead1c/setup.cfg#L48):

	pytest-mypy; python_implementation != "PyPy" and python_version < "3.10" and python_version > "3"

It has a python version constraint of <3.10 >3 and it seems invalid. And it breaks poetry. Related issue: python-poetry/poetry#534

The constraint mentioned above was not actually invalid. That case was resolved in #155.

This PR makes poetry can resolve dependencies with the broken constraints, such as python_version >= "3.6" and python_version <= "3.4"

pbzweihander pushed a commit to spoqa/requests-backoff that referenced this pull request Apr 2, 2021
pbzweihander pushed a commit to spoqa/requests-backoff that referenced this pull request Apr 2, 2021
pbzweihander pushed a commit to spoqa/requests-backoff that referenced this pull request Apr 2, 2021
@pawamoy
Copy link

pawamoy commented Apr 2, 2021

It has a python version constraint of <3.10 >3 and it seems invalid.

I don't think it's invalid. See python-poetry/poetry#3862 (comment) and the following comment.


assert dep.name == "pytest-mypy"
assert str(dep.constraint) == "*"
assert dep.python_versions == "<3.10 >=4"
Copy link

@pawamoy pawamoy Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://www.python.org/dev/peps/pep-0508/#versions and https://www.python.org/dev/peps/pep-0508/#environment-markers, I'd say Poetry should not consider > "3" to be equivalent to >= "4". These versions should be compared using PEP440, and with PEP440 3.6 is greater than 3, so the range specified in the mentioned marker is valid.

>>> import packaging
>>> from packaging import version
>>> version.parse("3.6") > version.parse("3")
True
>>> version.parse("3.6") >= version.parse("4")
False

@pawamoy
Copy link

pawamoy commented Apr 2, 2021

Anyway, your changes are still important for other invalid markers 👍

@pbzweihander pbzweihander force-pushed the resolve-invalid-python-version-constraint branch from 5167dd4 to e414556 Compare April 6, 2021 02:16
@pbzweihander
Copy link
Author

I have updated the tests for 'real' invalid constraint such as python_version >= "3.6" and python_version <= "3.4"

@pbzweihander
Copy link
Author

Oops, it seems like the test case with python_version >= "3.6" and python_version <= "3.4" does not produce EmptyConstraint...

@pbzweihander
Copy link
Author

I cannot come up with a python version constraint that produces EmptyConstraint. I'll just close this PR this moment. The actual issue was resolved in #155

@pbzweihander pbzweihander deleted the resolve-invalid-python-version-constraint branch April 8, 2021 04:20
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 this pull request may close these issues.

2 participants