Skip to content

Commit

Permalink
Sort BaseLockedDependency.dependencies when alpha-sorting a Lockfile (#…
Browse files Browse the repository at this point in the history
…654)

Sort BaseLockedDependency.dependencies when alpha-sorting a Lockfile

Co-authored-by: Ben Mares <[email protected]>
  • Loading branch information
peterbygrave and maresb authored Jun 30, 2024
1 parent cb7c402 commit ba347a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conda_lock/lockfile/v2prelim/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ def toposort_inplace(self) -> None:
self.package = self._toposort(self.package)

def alphasort_inplace(self) -> None:
# Sort the packages themselves by key (conda/pip, name, platform)
self.package.sort(key=lambda d: d.key())
for p in self.package:
# Also ensure that the dependencies of each package are sorted
# <https://github.com/conda/conda-lock/pull/654#issuecomment-2198453427>
p.dependencies = {
name: spec for name, spec in sorted(p.dependencies.items())
}

def filter_virtual_packages_inplace(self) -> None:
self.package = [
Expand Down

0 comments on commit ba347a0

Please sign in to comment.