-
Notifications
You must be signed in to change notification settings - Fork 34
Replace IndexedSet with Sequence / tuple; additional typing tweaks #879
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -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 | ||||||
|
|
||||||
|
|
@@ -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]: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| """ | ||||||
| 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]: | ||||||
|
|
@@ -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: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually put the more generic type in annotations. |
||||||
| """ | ||||||
| Operations that do not need a solver and might result in returning | ||||||
| early are collected here. | ||||||
|
|
||||||
| 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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 ...