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

Unhittable value error #6790

Merged
merged 1 commit into from Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/poetry/mixology/incompatibility.py
Expand Up @@ -5,7 +5,6 @@
from poetry.mixology.incompatibility_cause import ConflictCause
from poetry.mixology.incompatibility_cause import DependencyCause
from poetry.mixology.incompatibility_cause import NoVersionsCause
from poetry.mixology.incompatibility_cause import PackageNotFoundCause
from poetry.mixology.incompatibility_cause import PlatformCause
from poetry.mixology.incompatibility_cause import PythonCause
from poetry.mixology.incompatibility_cause import RootCause
Expand Down Expand Up @@ -146,11 +145,6 @@ def __str__(self) -> str:
f"no versions of {self._terms[0].dependency.name} match"
f" {self._terms[0].constraint}"
)
elif isinstance(self._cause, PackageNotFoundCause):
assert len(self._terms) == 1
assert self._terms[0].is_positive()

return f"{self._terms[0].dependency.name} doesn't exist"
elif isinstance(self._cause, RootCause):
assert len(self._terms) == 1
assert not self._terms[0].is_positive()
Expand Down Expand Up @@ -420,8 +414,6 @@ def _try_requires_forbidden(
buffer.append(f"which requires Python {cause.python_version}")
elif isinstance(latter.cause, NoVersionsCause):
buffer.append("which doesn't match any versions")
elif isinstance(latter.cause, PackageNotFoundCause):
buffer.append("which doesn't exist")
else:
buffer.append("which is forbidden")

Expand Down
14 changes: 0 additions & 14 deletions src/poetry/mixology/incompatibility_cause.py
Expand Up @@ -79,17 +79,3 @@ def __init__(self, platform: str) -> None:
@property
def platform(self) -> str:
return self._platform


class PackageNotFoundCause(IncompatibilityCause):
"""
The incompatibility represents a package that couldn't be found by its
source.
"""

def __init__(self, error: Exception) -> None:
self._error = error

@property
def error(self) -> Exception:
return self._error
32 changes: 4 additions & 28 deletions src/poetry/mixology/version_solver.py
Expand Up @@ -3,7 +3,6 @@
import functools
import time

from contextlib import suppress
from typing import TYPE_CHECKING

from poetry.core.packages.dependency import Dependency
Expand All @@ -12,7 +11,6 @@
from poetry.mixology.incompatibility import Incompatibility
from poetry.mixology.incompatibility_cause import ConflictCause
from poetry.mixology.incompatibility_cause import NoVersionsCause
from poetry.mixology.incompatibility_cause import PackageNotFoundCause
from poetry.mixology.incompatibility_cause import RootCause
from poetry.mixology.partial_solution import PartialSolution
from poetry.mixology.result import SolverResult
Expand Down Expand Up @@ -395,10 +393,8 @@ def _get_min(dependency: Dependency) -> tuple[bool, int, int]:
if locked:
return is_specific_marker, Preference.LOCKED, 1

try:
num_packages = len(self._dependency_cache.search_for(dependency))
except ValueError:
num_packages = 0
num_packages = len(self._dependency_cache.search_for(dependency))

if num_packages < 2:
preference = Preference.NO_CHOICE
elif use_latest:
Expand All @@ -414,28 +410,8 @@ def _get_min(dependency: Dependency) -> tuple[bool, int, int]:

locked = self._provider.get_locked(dependency)
if locked is None:
try:
packages = self._dependency_cache.search_for(dependency)
except ValueError as e:
self._add_incompatibility(
Incompatibility([Term(dependency, True)], PackageNotFoundCause(e))
)
complete_name: str = dependency.complete_name
return complete_name

package = None
if locked is not None:
package = next(
(
p
for p in packages
if p.package.version == locked.package.version
),
None,
)
if package is None:
with suppress(IndexError):
package = packages[0]
packages = self._dependency_cache.search_for(dependency)
package = next(iter(packages), None)

if package is None:
# If there are no versions that satisfy the constraint,
Expand Down