File tree 1 file changed +4
-13
lines changed
src/pip/_internal/resolution/resolvelib 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 1
1
import itertools
2
- import operator
3
2
4
3
from pip ._vendor .six .moves import collections_abc # type: ignore
5
4
@@ -31,19 +30,11 @@ def _insert_installed(installed, others):
31
30
This iterator is used when the resolver prefers to upgrade an
32
31
already-installed package. Candidates from index are returned in their
33
32
normal ordering, except replaced when the version is already installed.
34
-
35
- Since candidates from index are already sorted by reverse version order,
36
- `sorted()` here would keep the ordering mostly intact, only shuffling the
37
- already-installed candidate into the correct position. We put the already-
38
- installed candidate in front of those from the index, so it's put in front
39
- after sorting due to Python sorting's stableness guarentee.
40
33
"""
41
- candidates = sorted (
42
- itertools .chain ([installed ], others ),
43
- key = operator .attrgetter ("version" ),
44
- reverse = True ,
45
- )
46
- return iter (candidates )
34
+ for candidate in others :
35
+ if candidate .version == installed .version :
36
+ candidate = installed
37
+ yield candidate
47
38
48
39
49
40
class FoundCandidates (collections_abc .Sequence ):
You can’t perform that action at this time.
0 commit comments