Skip to content

Could not parse version constraint: <empty> #1782

@frostming

Description

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

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