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 update AttributeError: 'EmptyConstraint' object has no attribute 'allows' #4410

Closed
3 tasks done
mdengler opened this issue Aug 19, 2021 · 13 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@mdengler
Copy link

  • OS version and name: Fedora 34
$ cat /etc/fedora-release 
Fedora release 34 (Thirty Four)
  • Poetry version: Poetry version 1.1.6
$ poetry --version
Poetry version 1.1.6
  • Link of a Gist with the contents of your pyproject.toml file: Unpublished software, so if there is a need for this file, I can provide privately.

Issue

I have received this error message:

$ poetry update 
Updating dependencies                                                                                                                                         
Resolving dependencies... (34.4s)                                                                                                                             
                                                                                                                                                              
Writing lock file                                                                                                                                             
                                                                                                                                                              
  AttributeError                                                                                                                                              
                                                                                                                                                              
  'EmptyConstraint' object has no attribute 'allows'                                                                                                          
                                                                                                                                                              
  at ~/.local/lib/python3.9/site-packages/poetry/core/version/markers.py:291 in validate                                                                      
      287│                                                                                                                                                    
      288│         if self._name not in environment:                                                                                                          
      289│             return True                                                                                                                            
      290│                                                                                                                                                    
    → 291│         return self._constraint.allows(self._parser(environment[self._name]))                                                                      
      292│                                                                                                                                                    
      293│     def without_extras(self):  # type: () -> MarkerTypes                                                                                           
      294│         return self.exclude("extra")                                                                                                               
      295│                                                  

I made this change as a workaround:

$ diff -uw ~/.local/lib/python3.9/site-packages/poetry/core/version/markers.py{~,}
--- /home/martin/.local/lib/python3.9/site-packages/poetry/core/version/markers.py~     2021-04-21 11:44:56.085692322 -0400
+++ /home/martin/.local/lib/python3.9/site-packages/poetry/core/version/markers.py      2021-08-19 11:38:17.934769254 -0400
@@ -288,6 +288,9 @@
         if self._name not in environment:
             return True
 
+        if not hasattr(self._constraint, "allows"):
+            return True
+
         return self._constraint.allows(self._parser(environment[self._name]))
 
     def without_extras(self):  # type: () -> MarkerTypes
$ diff -uw ~/.local/lib/python3.9/site-packages/poetry/core/version/markers.py{~,}
--- /home/martin/.local/lib/python3.9/site-packages/poetry/core/version/markers.py~     2021-04-21 11:44:56.085692322 -0400
+++ /home/martin/.local/lib/python3.9/site-packages/poetry/core/version/markers.py      2021-08-19 11:38:17.934769254 -0400
@@ -288,6 +288,9 @@
         if self._name not in environment:
             return True
 
+        if not hasattr(self._constraint, "allows"):
+            return True
+
         return self._constraint.allows(self._parser(environment[self._name]))
 
     def without_extras(self):  # type: () -> MarkerTypes

I gathered some extra debugging information that points to greenlet and sqlalchemy as being involved in the issue: https://gist.github.com/mdengler/7be12f9c481567c7872bc2ea712464b6

@mdengler mdengler added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 19, 2021
@elbakramer
Copy link

Upgrading poetry to 1.1.8 may solve the issue.
Check #4402 for for more information.

@mdengler
Copy link
Author

Thanks -- looks like this is a dupe, then.

@mrtolkien
Copy link

I have the same issue with the current preview build, poetry 1.2.0a2

Will there be another preview build that fixes it?

@bipinkc19
Copy link

I have the same issue with the current preview build, poetry 1.2.0a2

Will there be another preview build that fixes it?

Been getting the same problem.

@alanorth
Copy link

alanorth commented Sep 4, 2021

I'm doing poetry update with poetry 1.1.8 on a project that indirectly includes sqlalchemy and I get this error too:

$ poetry update                                                                                                  
Updating dependencies                                                                                                                                          
Resolving dependencies... (1.3s)                                                                                                                               
                                                                                                                                                               
  AttributeError                                                                                                                                               
                                                                                                                                                               
  'EmptyConstraint' object has no attribute 'allows'                                                                                                           
                                                                                                                                                               
  at /usr/lib/python3.9/site-packages/poetry/core/version/markers.py:291 in validate                                                                           
      287│                                                                                                                                                     
      288│         if self._name not in environment:                                                                                                           
      289│             return True                                                                                                                             
      290│                                                                                                                                                     
    → 291│         return self._constraint.allows(self._parser(environment[self._name]))                                                                       
      292│                                                                                                                                                     
      293│     def without_extras(self):  # type: () -> MarkerTypes                                                                                            
      294│         return self.exclude("extra")                                                                                                                
      295│   

Link to pyproject.toml.

@tcaiazza
Copy link

tcaiazza commented Sep 7, 2021

I get the same error as others, 'EmptyConstraint' object has no attribute 'allows' and through some trail and error it looks like the issue is with sqlalchemy version 1.4.23. If I pin it to 1.4.22 everything works as expected.

Note: i'm using poetry 1.2.0a1

@mahenzon
Copy link

mahenzon commented Sep 8, 2021

Yeah, happens with sqlalchemy

[[package]]
name = "sqlalchemy"
version = "1.4.23"
description = "Database Abstraction Library"
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"

[package.dependencies]
greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32\""}

platform_machine in "x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32" seems to be unexpected for poetry

@alanorth
Copy link

alanorth commented Sep 9, 2021

@errsolve7 this is not solved with Poetry 1.1.8 or current master, as several commenters and I have noted.

@sodality-ramsey
Copy link

[Already Solved] AttributeError ‘EmptyConstraint’ object has no attribute ‘allows’

Please do not follow this link, this user is attempting a phishing scam. Comment is reported.

As an aside, updating to Poetry 1.1.8 fixed the AttributeError: 'EmptyConstraint' object has no attribute 'allows' error for me.

@mahenzon
Copy link

mahenzon commented Sep 9, 2021

Yeah, fixed for me too in 1.1.8, was getting it with 1.1.7

@pengfei99
Copy link

Also fixed for me too in 1.1.8, was getting it with 1.1.6

@fulopkovacs
Copy link

fulopkovacs commented Oct 1, 2021

I get the same error as others, 'EmptyConstraint' object has no attribute 'allows' and through some trail and error it looks like the issue is with sqlalchemy version 1.4.23. If I pin it to 1.4.22 everything works as expected.

Note: i'm using poetry 1.2.0a1

Pinning sqlalchemy to 1.4.22 solved this problem for me too (I'm using poetry 1.1.0). What's weird is that this problem does not occur in our CI where we use images based on python:3.6.x-slim and python:3.8.x. I have Python 3.9 installed on my computer (Manjaro Linux) and all the previous commenters whose logs I've seen so far are using Python 3.9 too. Maybe it's an issue with Python 3.9? Just a thought, though, I haven't actually tested it.

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
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

No branches or pull requests

12 participants