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

poetry lock failing with OverrideNeeded and AssertionError on 1.2.0b2 #5791

Closed
spoorn opened this issue Jun 7, 2022 · 6 comments · Fixed by python-poetry/poetry-core#395
Closed
Labels
kind/bug Something isn't working as expected

Comments

@spoorn
Copy link
Contributor

spoorn commented Jun 7, 2022

  • [ x ] I am on the latest Poetry version.
  • [ x ] I have searched the issues of this repo and believe that this is not a duplicate.
  • [ x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: AmazonLinux 2/Ubuntu
  • Poetry version: 1.2.0b2
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

A simple poetry lock fails when I updated to 1.2.0b2. Downgrading to 1.2.0b1 succeeds the command as usual.

Error:

% poetry lock -v
Using virtualenv: /local/home/user/.virtualenvs/test
Updating dependencies
Resolving dependencies... (1.9s)

  OverrideNeeded

  ({Package('pandas', '1.4.2'): {'numpy': <Dependency numpy (>=1.18.5)>}}, {Package('pandas', '1.4.2'): {'numpy': <Dependency numpy (>=1.19.2)>}}, {Package('pandas', '1.4.2'): {'numpy': <Dependency numpy (>=1.20.0)>}})

  at ~/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/puzzle/provider.py:757 in complete_package
      753│                     current_overrides.update({package: package_overrides})
      754│                     overrides.append(current_overrides)
      755│
      756│             if overrides:
    → 757│                 raise OverrideNeeded(*overrides)
      758│
      759│         # Modifying dependencies as needed
      760│         clean_dependencies = []
      761│         for dep in dependencies:

The following error occurred when trying to handle this error:


  AssertionError



  at ~/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/mixology/partial_solution.py:151 in _register
      147│         name = assignment.dependency.complete_name
      148│         old_positive = self._positive.get(name)
      149│         if old_positive is not None:
      150│             value = old_positive.intersect(assignment)
    → 151│             assert value is not None
      152│             self._positive[name] = value
      153│
      154│             return
      155│
@spoorn spoorn added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 7, 2022
@spoorn
Copy link
Contributor Author

spoorn commented Jun 7, 2022

Found out this happens if gluoncv = "0.10.5" is in pyproject.toml. Even if that's the only dependency I have in the entire file

@dimbleby
Copy link
Contributor

dimbleby commented Jun 7, 2022

https://github.com/python-poetry/poetry-core/blob/2bfcbe49dd887e1527e4e5e22cbd14caf4d9126a/src/poetry/core/semver/version.py#L92-L94 has the result that the constraint "=0.10.5" allows the version "0.10.5.post0".

But because this is unsymmetrical: when we intersect the constraints "==0.10.5" and "==0.10.5.post0" we get <empty>.

#379 is potentially relevant, inasmuch as it looks as though it introduces a similar asymmetry for local labels. (But if I'm right that introduces more instances of this problem, rather than fixing any.)

@dimbleby
Copy link
Contributor

dimbleby commented Jun 7, 2022

maybe allows is supposed to be unsymmetrical, but symmetry on intersection should be restored somehow?

@dimbleby
Copy link
Contributor

dimbleby commented Jun 7, 2022

diff --git a/src/poetry/core/semver/version.py b/src/poetry/core/semver/version.py
index 417d23a..356ac9e 100644
--- a/src/poetry/core/semver/version.py
+++ b/src/poetry/core/semver/version.py
@@ -107,6 +107,9 @@ class Version(PEP440Version, VersionRangeConstraint):
         if other.allows(self):
             return self

+        if isinstance(other, Version) and self.allows(other):
+            return other
+
         return EmptyConstraint()

     def union(self, other: VersionConstraint) -> VersionConstraint:

perhaps.

@radoering
Copy link
Member

But because this is unsymmetrical: when we intersect the constraints "==0.10.5" and "==0.10.5.post0" we get <empty>.

Interestingly enough, according to PEP 440, I'd say it is correct that the intersection is empty. However, "==0.10.5" should not allow the version "0.10.5.post0" so the post release should never be selected in this example. I created python-poetry/poetry-core#396 to address this.

Copy link

github-actions bot commented Mar 2, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants