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

Could not parse version constraint: <empty> #1782

Closed
3 tasks done
frostming opened this issue Dec 21, 2019 · 1 comment · Fixed by #1789
Closed
3 tasks done

Could not parse version constraint: <empty> #1782

frostming opened this issue Dec 21, 2019 · 1 comment · Fixed by #1789
Labels
kind/bug Something isn't working as expected

Comments

@frostming
Copy link
Contributor

frostming commented Dec 21, 2019

  • 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).
  • OS version and name: macOS 10.15.2
  • Poetry version: 1.0.0(master branch in fact)
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

The following lines:

if not package.dependency.python_constraint.is_any():
dep.transitive_python_versions = str(
dep.python_constraint.intersect(
package.dependency.python_constraint
)

When the package python constraint(e.g. We want flake8 for python >=3.6 only, it doesn't overlap with dep python constraint(e.g. configparser is only needed for python <3.2), it means configparser is not required at all and shouldn't be listed in the lock result. However, in this case poetry will throw a Could not parse version constraint: <empty> error because the intersection version is <empty>.

Error detail:

Traceback (most recent call last):
  File "/Users/fming/.virtualenvs/poetry-ZHUPScpV-py3.7/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/fming/.virtualenvs/poetry-ZHUPScpV-py3.7/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/fming/.virtualenvs/poetry-ZHUPScpV-py3.7/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/fming/.virtualenvs/poetry-ZHUPScpV-py3.7/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/fming/wkspace/github/poetry/poetry/console/commands/add.py", line 149, in handle
    status = installer.run()
  File "/Users/fming/wkspace/github/poetry/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/Users/fming/wkspace/github/poetry/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/Users/fming/wkspace/github/poetry/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/Users/fming/wkspace/github/poetry/poetry/puzzle/solver.py", line 181, in _solve
    self._package, self._provider, locked=locked, use_latest=use_latest
  File "/Users/fming/wkspace/github/poetry/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/Users/fming/wkspace/github/poetry/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/Users/fming/wkspace/github/poetry/poetry/mixology/version_solver.py", line 378, in _choose_package_version
    version = self._provider.complete_package(version)
  File "/Users/fming/wkspace/github/poetry/poetry/puzzle/provider.py", line 678, in complete_package
    package.dependency.python_constraint
  File "/Users/fming/wkspace/github/poetry/poetry/packages/dependency.py", line 118, in transitive_python_versions
    self._transitive_python_constraint = parse_constraint(value)
  File "/Users/fming/wkspace/github/poetry/poetry/semver/__init__.py", line 31, in parse_constraint
    constraint_objects.append(parse_single_constraint(and_constraints[0]))
  File "/Users/fming/wkspace/github/poetry/poetry/semver/__init__.py", line 164, in parse_single_constraint
    raise ValueError('Could not parse version constraint: {}'.format(constraint))

Steps to replicate

$ poetry add -D -vvv --python ">=3.6" pytest

Possible related:

#1484

@frostming frostming added the kind/bug Something isn't working as expected label Dec 21, 2019
Copy link

github-actions bot commented Mar 3, 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 3, 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.

1 participant