pip: PipProvider._known_depths sets depths to math.inf incorrectly
Description
While investigating #10201 using the following requirements:
pytest-cov
coverage==4.5.4
boto3
I printed out the inferred_depth
in the method PipProvider.get_preference
and noticed that almost all the packages, other than those listed above, had their inferred_depth
calculated as math.inf
.
Expected behavior
The actual inferred depth should be calculated. This can be fixed by moving the line to after the try/except statement:
self._known_depths[identifier] = inferred_depth
E.g. changing the code to:
try:
requested_order: Union[int, float] = self._user_requested[identifier]
except KeyError:
requested_order = math.inf
parent_depths = (
self._known_depths[parent.name] if parent is not None else 0.0
for _, parent in information[identifier]
)
inferred_depth = min(d for d in parent_depths) + 1.0
else:
inferred_depth = 1.0
self._known_depths[identifier] = inferred_depth
pip version
21.2.4
Python version
all
OS
all
How to Reproduce
- Run pip install/download on the above requirements text
Output
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
Yes, thanks for noticing it!