1- import collections
21import math
32from functools import lru_cache
43from typing import (
@@ -100,7 +99,6 @@ def __init__(
10099 self ._ignore_dependencies = ignore_dependencies
101100 self ._upgrade_strategy = upgrade_strategy
102101 self ._user_requested = user_requested
103- self ._known_depths : Dict [str , float ] = collections .defaultdict (lambda : math .inf )
104102
105103 def identify (self , requirement_or_candidate : Union [Requirement , Candidate ]) -> str :
106104 return requirement_or_candidate .name
@@ -124,10 +122,6 @@ def get_preference(
124122 explicit URL.
125123 * If equal, prefer if any requirement is "pinned", i.e. contains
126124 operator ``===`` or ``==``.
127- * If equal, calculate an approximate "depth" and resolve requirements
128- closer to the user-specified requirements first. If the depth cannot
129- by determined (eg: due to no matching parents), it is considered
130- infinite.
131125 * Order user-specified requirements by the order they are specified.
132126 * If equal, prefers "non-free" requirements, i.e. contains at least one
133127 operator, such as ``>=`` or ``<``.
@@ -157,23 +151,6 @@ def get_preference(
157151 direct = candidate is not None
158152 pinned = any (op [:2 ] == "==" for op in operators )
159153 unfree = bool (operators )
160-
161- try :
162- requested_order : Union [int , float ] = self ._user_requested [identifier ]
163- except KeyError :
164- requested_order = math .inf
165- if has_information :
166- parent_depths = (
167- self ._known_depths [parent .name ] if parent is not None else 0.0
168- for _ , parent in information [identifier ]
169- )
170- inferred_depth = min (d for d in parent_depths ) + 1.0
171- else :
172- inferred_depth = math .inf
173- else :
174- inferred_depth = 1.0
175- self ._known_depths [identifier ] = inferred_depth
176-
177154 requested_order = self ._user_requested .get (identifier , math .inf )
178155
179156 # Requires-Python has only one candidate and the check is basically
@@ -190,7 +167,6 @@ def get_preference(
190167 not direct ,
191168 not pinned ,
192169 not backtrack_cause ,
193- inferred_depth ,
194170 requested_order ,
195171 not unfree ,
196172 identifier ,
0 commit comments