PipProvider._known_depths sets depths to math.inf incorrectly
See original GitHub issueDescription
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Python math.inf Constant - W3Schools
inf constant returns a floating-point positive infinity. For negative infinity, use -math.inf . The inf constant is equivalent to float('inf') . Syntax.
Read more >How can I represent an infinite number in Python?
In Python, you can do: test = float("inf"). In Python 3.5, you can do: import math test = math.inf. And then: test >...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, thanks for noticing it!
Can this be closed now that #10482 has merged? 😃