-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix constraint reporting in dependency conflict resolution logs #13545 #13570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix constraint reporting in dependency conflict resolution logs #13545 #13570
Conversation
Thanks for the PR to pip, please be aware all maintainers are volunteers and it may take some time to review your PR. I do like you are trying to solve this issue (although providing an example where the constraint caused the dependency conflict issue would be more useful). But I do not like the approach, dynamically adding the provider instance to the reporter instance as a private variable has a number of issues. Those two classes are supposed to be independent of each other, that's why they are two separate classes in the first place. It also creates a situation where private variables of another class are being accessed, the point of private variables is not to do that. I would need to spend some time reviewing to suggest a better approach though, which I will do at some point (currently my review queue is quite long so it might take a couple of months) if you don't know how to address or another reviewer isn't able to help. |
…vider reference - Remove dynamic provider assignment that violated separation of concerns - Pass constraints directly to PipReporter constructor - Maintain clean architecture while preserving constraint reporting functionality - Addresses reviewer feedback about private variable access across classes
Thanks for the feedback, @notatallshaw ! |
@ShubhamNagure I would definitely prefer that approach if it's workable, but I haven't looked at it, so I don't know. |
…hubhamNagure/pip into fix-constraint-reporting-13545
The original PipReporter class did not have these methods. Keep the PR minimal and focused on the constraint reporting fix.
Looking a lot better! I will try and review soon, but I can't make any promises. |
Fix: Include user-supplied constraints in dependency conflict resolution logs
Problem Description
Fixes #13545
When pip encounters dependency conflicts during resolution, the log messages currently omit user-supplied constraints from the conflict description, making it difficult for users to understand why certain packages are being rejected.
Current Behavior
When a constraint file specifies version limits that conflict with package requirements, the resolver logs show incomplete information:
Missing: The user-supplied constraint
fsspec<=2026
from the constraint file is not mentioned.Expected Behavior
The logs should include all relevant constraints to provide complete context:
Solution
Changes Made
Enhanced PipReporter class (
src/pip/_internal/resolution/resolvelib/reporter.py
):_provider
attribute to access constraint informationrejecting_candidate
method to include constraint details in rejection messagesUpdated Resolver integration (
src/pip/_internal/resolution/resolvelib/resolver.py
):reporter._provider = provider
Added changelog entry (
news/13545.bugfix.rst
):Technical Implementation
The fix works by:
Testing
Reproduction Test Case
Verification
Test Results
Before fix: Constraint information missing from conflict logs
After fix: Complete constraint information included in rejection messages
Checklist
news/
directoryCode Review Notes
Why This Approach?
Alternative Approaches Considered
Performance Impact
Impact
This change improves the debugging experience for users dealing with complex dependency conflicts involving constraints, making it easier to understand why certain package versions are being rejected during resolution.
The fix maintains full backward compatibility while providing more informative logging that helps users troubleshoot constraint-related dependency issues more effectively.
Time invested
5 hours and 2 cup of coffee