Fix pip config parsing for multiple extra-index-urls#3125
Fix pip config parsing for multiple extra-index-urls#3125harkrish-1 wants to merge 2 commits intoNetflix:masterfrom
Conversation
When pip config contains multiple extra-index-urls, `pip config list` outputs them separated by literal `\n` characters. The previous regex only split on whitespace, so multiple URLs were treated as a single mangled value. Split on literal `\n` as well. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes Confidence Score: 5/5Safe to merge; the fix is correct, the test validates the regression, and the only remaining finding is a minor defensive-coding suggestion. No P0 or P1 issues. The single finding (empty strings from split) is a pre-existing edge case that the PR doesn't worsen in any realistic pip output scenario, and is P2 only. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "Add unit tests for Pip.indices() config ..." | Re-trigger Greptile |
Regression test for the literal \n splitting fix plus coverage for single index, extra-index, multiple-index priority, empty config, and config call failure scenarios. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cd6e827 to
5744f99
Compare
|
@savingoyal @saikonen please review and add your feedback. Simple one line change, shouldn't need a lot of time to review. |
| @@ -0,0 +1,24 @@ | |||
| from unittest.mock import patch | |||
There was a problem hiding this comment.
Please use pytest, magicmock (pytest-mock plugin), and monkeypatch for the tests. Within pytest, we prefer to use fixtures and non-class-based tests.
|
Also make sure to setup the pre-commit hooks insce your code fails on the |
|
Also the appropriate location for this test file should be inside |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3125 +/- ##
=========================================
Coverage ? 26.22%
=========================================
Files ? 375
Lines ? 51431
Branches ? 9069
=========================================
Hits ? 13489
Misses ? 37155
Partials ? 787 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| _, key = key.split(".") | ||
| if key in ("index-url", "extra-index-url"): | ||
| values = map(lambda x: x.strip("'\""), re.split("\s+", value, re.M)) | ||
| values = map(lambda x: x.strip("'\""), re.split(r"\\n|\s+", value, re.M)) |
There was a problem hiding this comment.
Change looks straightforward, good catch with this one.
Can you address the other pending review comments still? Otherwise this is good to go.
Summary
Pip.indices()to correctly parse multipleextra-index-urlvalues from pip configpip config listoutputs them separated by literal\ncharacters (backslash + n, not actual newlines)\s+) only split on whitespace, so multiple URLs were treated as a single mangled value\nas an additional split delimiter:r"\\n|\s+"Tests
Non-Goals
AI Tool Usage
Used claude code to identify and fix this bug, I completely understand the changes made