Skip to content

poetry update AttributeError: 'EmptyConstraint' object has no attribute 'allows' #4410

Closed

Description

@mdengler
  • 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

Activity

  1. added
    kind/bugSomething isn't working as expected
    status/triageThis issue needs to be triaged
    on Aug 19, 2021
  2. elbakramer commented on Aug 19, 2021

    @elbakramer

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

  3. mdengler commented on Aug 19, 2021

    @mdengler
    Author

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

  4. mrtolkien commented on Aug 26, 2021

    @mrtolkien

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

    Will there be another preview build that fixes it?

  5. bipinkc19 commented on Sep 2, 2021

    @bipinkc19

    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.

  6. alanorth commented on Sep 4, 2021

    @alanorth

    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.

  7. tcaiazza commented on Sep 7, 2021

    @tcaiazza

    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

  8. mahenzon commented on Sep 8, 2021

    @mahenzon

    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

  9. alanorth commented on Sep 9, 2021

    @alanorth

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

  10. sodality-ramsey commented on Sep 9, 2021

    @sodality-ramsey

    [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.

  11. mahenzon commented on Sep 9, 2021

    @mahenzon

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

  12. pengfei99 commented on Sep 11, 2021

    @pengfei99

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

  13. fulopkovacs commented on Oct 1, 2021

    @fulopkovacs

    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.

  14. github-actions commented on Mar 2, 2024

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions