question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PipProvider._known_depths sets depths to math.inf incorrectly

See original GitHub issue

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

  1. Run pip install/download on the above requirements text

Output

No response

Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Oct 12, 2021

Yes, thanks for noticing it!

0reactions
edmorleycommented, Oct 12, 2021

Can this be closed now that #10482 has merged? 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found