Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions conda_libmamba_solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence

from boltons.setutils import IndexedSet
from conda.auxlib import _Null
from conda.base.constants import (
DepsModifier,
Expand Down Expand Up @@ -139,7 +138,7 @@ def solve_final_state(
ignore_pinned: bool | _Null = NULL,
force_remove: bool | _Null = NULL,
should_retry_solve: bool = False,
) -> IndexedSet[PackageRecord]:
) -> Sequence[PackageRecord]:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base class only says (in an inaccurate docstring) that this returns a tuple of PackageRef

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can go with the more accurate:

Suggested change
) -> Sequence[PackageRecord]:
) -> tuple[PackageRecord, ...]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tuple is more concrete, but Sequence is accurate and has a nicer "all elements of the same type" annotation without ...

self._log_info()
in_state = SolverInputState(
prefix=self.prefix,
Expand Down Expand Up @@ -301,14 +300,14 @@ def _solving_loop(
in_state: SolverInputState,
out_state: SolverOutputState,
index: LibMambaIndexHelper,
) -> IndexedSet[PackageRecord]:
) -> SolverOutputState:
solved = False
for attempt in range(1, self._max_attempts(in_state) + 1):
try:
solved, outcome = self._solve_attempt(in_state, out_state, index, attempt=attempt)
if solved:
break
except (UnsatisfiableError, PackagesNotFoundError):
solved = False
break # try with last attempt
else: # didn't solve yet, but can retry
out_state = SolverOutputState(
Expand Down
9 changes: 4 additions & 5 deletions conda_libmamba_solver/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
from types import MappingProxyType
from typing import TYPE_CHECKING

from boltons.setutils import IndexedSet
from conda.auxlib import NULL
from conda.base.constants import DepsModifier, UpdateModifier
from conda.base.context import context
Expand All @@ -82,7 +81,7 @@
from conda.models.prefix_graph import PrefixGraph

if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Iterable, Sequence
from os import PathLike
from typing import Any

Expand Down Expand Up @@ -472,12 +471,12 @@ def __init__(
self.pins: dict[str, MatchSpec] = pins or {}

@property
def current_solution(self) -> IndexedSet[PackageRecord]:
def current_solution(self) -> Sequence[PackageRecord]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def current_solution(self) -> Sequence[PackageRecord]:
def current_solution(self) -> tuple[PackageRecord, ...]:

"""
Massage currently stored records so they can be returned as the type expected by the
solver API. This is what you should return in ``Solver.solve_final_state()``.
"""
return IndexedSet(PrefixGraph(self.records.values()).graph)
return tuple(PrefixGraph(self.records.values()).graph)

@property
def specs(self) -> dict[str, MatchSpec]:
Expand Down Expand Up @@ -519,7 +518,7 @@ def virtual_specs(self) -> dict[str, MatchSpec]:
"""
return {name: spec for name, spec in self.specs.items() if name.startswith("__")}

def early_exit(self) -> IndexedSet[PackageRecord] | None:
def early_exit(self) -> Sequence[PackageRecord] | None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def early_exit(self) -> Sequence[PackageRecord] | None:
def early_exit(self) -> tuple[PackageRecord, ...] | None:

Copy link
Copy Markdown
Contributor Author

@dholth dholth Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually put the more generic type in annotations. Sequence[] would allow IndexedSet or tuple or list for example. Especially in the base class in conda.

"""
Operations that do not need a solver and might result in returning
early are collected here.
Expand Down
1 change: 0 additions & 1 deletion dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# build-time
pip
# run-time
boltons>=23.0.0
conda>=26.1
conda-forge::libmamba>=2.0.0
conda-forge::libmambapy>=2.0.0
Expand Down
20 changes: 20 additions & 0 deletions news/drop-indexedset
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* Replace `IndexedSet` with simple de-duplication using builtins. Drop `boltons`
dependency. Requires an unreleased version of conda.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"conda >=26.1",
"conda >=26.5",
# "libmambapy >=2",
"boltons >=23.0.0",
"msgpack >=1.1.1",
"requests >=2.28.0,<3",
"zstandard >=0.15"
Expand Down
3 changes: 1 addition & 2 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ requirements:
- hatch-vcs
run:
- python >=3.10
- conda >=26.1
- conda >=26.5
- libmambapy >=2.0.0
- boltons >=23.0.0
- msgpack-python >=1.1.1
- requests >=2.28.0,<3
- zstandard >=0.15
Expand Down
Loading