-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
'EmptyConstraint' object has no attribute 'min' with pytest and Python 2.7 #3862
Comments
We started seeing this same error yesterday as well. I'm guessing some dependency in the tree did a release recently that is somehow exposing this bug. |
After some debugging I think I narrowed down the problem to a recent backports.functools-lru-cache package release. Changing the dev-deps to this still reproduces the problem: [tool.poetry.dev-dependencies]
"backports.functools-lru-cache" = "*" As a temporary workaround, you can pin this dependency back like this: "backports.functools-lru-cache" = "1.6.1" poetry seems to be tripping up on this line from their
|
Thanks for the workaround, @Nitori- ! |
Experiencing the same thing with |
My suspicion is that there might be another dependency out in the wild that also exposes the bug. If you can get poetry onto a debugger that's how I found out that the lru-cache package was causing issues. |
I patched Poetry's source to catch the exception and print the package name:
try:
dep.python_versions = " || ".join(ors)
except AttributeError:
print(name) The output showed |
If you jump up maybe 2-3 stacks, you'll see the package that was depending on pytest-mypy. That's probably the one that needs to get pinned. |
@pawamoy I did some digging and the issue you're seeing is from Of course, all of this is just workarounds. It's still fundamentally a bug in poetry that can't seem to handle this dependency line:
|
Damn, I can't work on any project now, nothing will resolve 😅 |
I wonder if
Poetry should maybe simply catch the try:
# Attempt to parse the PEP-508 requirement string
dependency = dependency_from_pep_508(req, relative_to=root_dir)
except InvalidMarker:
# Invalid marker, We strip the markers hoping for the best
req = req.split(";")[0]
dependency = dependency_from_pep_508(req, relative_to=root_dir)
except ValueError:
# Likely unable to parse constraint so we skip it
self._log(
"Invalid constraint ({}) found in {}-{} dependencies, "
"skipping".format(req, package.name, package.version),
level="warning",
)
continue |
|
@dkasak maybe! However I think it's parsed as precision 1, entering this condition: if parsed_version.precision == 1:
if op == "<=":
op = "<"
version = parsed_version.next_major.text
elif op == ">":
op = ">="
version = parsed_version.next_major.text (and so it's changing it to I guess we'll need to read the spec to decide if it's correct or not! |
OK, PEP508 says versions comparison is done according to PEP440. |
And using PEP440 version parsing, it seems Poetry should not consider >>> import packaging
>>> from packaging import version
>>> version.parse("3.6") > version.parse("3")
True
>>> version.parse("3.6") >= version.parse("4")
False |
Poetry core has a 1.1.0a1 release that refactored all this, I'll try it and report back. |
Ah, there's a related PR python-poetry/poetry-core#154 |
I've identified the package who recently released a new version depending on backports.entry_points_selectable: pytest-randomly v3.6.0: pytest-dev/pytest-randomly@3.5.0...3.6.0 (look at requirements.in) I was able to fix that issue in CI with the following hack: - name: Set up Poetry
# HACK: https://github.com/python-poetry/poetry-core/pull/154
run: |
pip install git+https://github.com/python-poetry/poetry
pip uninstall -y poetry-core
pip install git+https://github.com/pbzweihander/poetry-core@resolve-invalid-python-version-constraint But I guess I should simply downgrade and pin pytest-randomly to 3.5.0 🙂 |
Thanks for the quick work on this, @sdispater et. al! |
I would love to see this fix released, as it hits me really hard in all (>50) of my projects. |
…version 1.0.3 to version 1.0.4 v1.0.4 ====== #2: For test dependencies, when indicating Python 3, use ``>=3`` instead of ``>3`` to satisfy `python-poetry/poetry#3862 <https://github.com/python-poetry/poetry/issues/3862>`_.
v1.6.4 For test dependencies, when indicating Python 3, use ``>=3`` instead of ``>3`` to satisfy `python-poetry/poetry#3862 <https://github.com/python-poetry/poetry/issues/3862>`_. v1.6.3 Restore universal wheel. v1.6.2 Packaging refresh.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
I've discovered a bug that arises when
pytest
is combined with Python^2.7
inpyproject.toml
. The Gist linked above provides a minimal example of this issue. Runningpoetry lock
with the above file results in the following exception:The error does not appear if either
pytest
is removed or the Python version is changed to^3.6
. I originally reported this as part of #2372, but then realized that that issue related to error handing in response to an error inpyproject.toml
. As this error occurs in a correctly-formattedpyproject.toml
, I believe it is a distinct issue.The text was updated successfully, but these errors were encountered: