poetry: AttributeError : EmptyConstraint object has no attribute allows
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- Linux Pop!_OS 21.04
- Poetry 1.1.7
[tool.poetry.dependencies]
python = "^3.8"
click = "*"
python-dotenv = "*"
pandas = "*"
requests = "*"
pydantic = "*"
sqlalchemy = "*"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.black]
skip-string-normalization = true
Issue
Tried both with python3.8 and python3.9 resulting in this same error.
AttributeError
'EmptyConstraint' object has no attribute 'allows'
at ~/anaconda3/envs/py38/lib/python3.8/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│
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 39
- Comments: 18 (4 by maintainers)
Seems to be an issue with SQLAlchemy 1.4.23 that was released ~3 hours ago. Can someone open an issue with them if not already? After work, I can submit an issue otherwise
A temporary workaround is pinning to 1.4.22 (
sqlalchemy="1.4.22"
)the problem seems to be with the newest
sqlalchemy
in my case …Put up https://github.com/python-poetry/poetry-core/pull/187. Hopefully it’s correct, and fixes this issue.
From inspecting the object with the EmptyMarker:
And inspecting my lockfile:
I have a hunch the issue might be the
greenlet
dependency, which in my case is required bysqlalchemy
.Sure, here is the full stacktrace (for python3.9 this time)
On closer inspection, I’m not sure whether this issue should be raised in poetry core? It does appear the bug exists on master (https://github.com/python-poetry/poetry-core/blob/5812d6db7ae95ac0dd11b498e47f3c3f17a27857/poetry/core/packages/constraints/empty_constraint.py#L10) Edit: Neither BaseConstraint, nor EmptyConstraint have an
allows
method, even though all the other concrete constraint implementations do. The check in markers.py appears to be crashing with deps that have no constraints as a result of this mismatch in the interface. I’m guess this maybe never came up because it’s extremely rare to have no constraint on a dependency.hey there -
this is a poetry issue. SQLAlchemy is using https://www.python.org/dev/peps/pep-0508/ specifiers and as far as we can tell, the syntax is valid. There is no issue with our software installing with pip.
I wonder if a single package was pushed to PyPi with an empty constraint and we all happen to reference it? I’m working through the dependencies for our project now
No, the fix was made in poetry-core. In the 1.0 branch and the master branch. There was a release 1.0.4 which is used by poetry 1.1.8. But the poetry preview release still uses poetry-core 1.1.0a6. I think with the next preview release of poetry, there will be also a new release for poetry-core which then contains the fix…
This is a bug. Is a very obvious bug for 1.1.7. The EmptyConstraint class does not implement the allows method. Just implementing it to return True appeared to fix it in my case, though I’m not clear entirely clear if a blanket True is the correct behaviour.