Rewrite urllib3 retry warnings to be understandable #14242
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.44) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 228 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.325
Real PR Conversation Timeline
1 comments
"Review active on #14242"
general
weight: 0.35
ichard26
Towards https://github.com/pypa/pip/issues/10421. This is in draft until https://github.com/urllib3/urllib3/pull/5140 is included in a urllib3 release.
The approach taken here is to install a logging filter on the
_vendorlogging handler which "sniffs" for the appropriate warnings and rewrites them. This rewriting is best effort because urllib3 gives us scant context to work with. Under verbose mode, the original error is appended as a "here's all of the context, sorry that it's unreadable" aid.This is supported by an upstream PR to urllib3 (https://github.com/urllib3/urllib3/pull/5140) adding a special extra attribute to the retrying warning, providing for a clear identifying marker and extra information needed by pip (i.e. the target host).
Overall, this is quite hacky, but having discussed with the urllib3 maintainers, this is the most mutually acceptable compromise for improving these user-hostile warnings for pip.
Example screenshots (and a question!)
<img width="2878" height="402" alt="image" src="https://github.com/user-attachments/assets/46935673-efd1-4b0e-b318-80e40fa9fbda" />
<img width="2844" height="408" alt="image" src="https://github.com/user-attachments/assets/95ecba91-9ecc-4544-ba75-f9490b008202" />
<img width="2880" height="440" alt="image" src="https://github.com/user-attachments/assets/896e9a16-182a-4197-8a0c-1164d0cbe133" />
... looking at these screenshots, I wonder if would be better to include the URL path that's being retried. While it's clear from context what URLs are being retried in these screeenshots, in other cases, the URL cannot be easily inferred. OTOH, some URLs are truly long (like PyPI's
files.pythonhosted.orgdistribution URLs) and we probably don't want to print said URLs repeatedly. Let me know if you have any opinions.