Skip to content

Handle Python requirements with no version specifier in the requirement file updater - #16323

Merged
v-kbukum1 merged 1 commit into
mainfrom
kbukum1/python-uv-requirement-no-version-specifier
Sep 18, 2026
Merged

v-kbukum1 merged 1 commit into
mainfrom
kbukum1/python-uv-requirement-no-version-specifier

Conversation

@v-kbukum1

@v-kbukum1 v-kbukum1 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

The Python requirement file updater assumed every requirement carries a version specifier and crashed with a TypeError when one did not. A missing version specifier is valid per PEP 508 and the pip requirements format — bare names, URL/VCS/editable/local-path direct references, unpinned pip-tools inputs, and PEP 621 / [tool.uv.sources] entries. This change makes the updater handle that case gracefully. uv reuses the Python updater, so the fix covers pip and uv.

Anything you want to highlight for special attention from reviewers?

  • Key decision: no-op skip when there is no specifier to rewrite, rather than raising a typed error. The upstream requirements updater already declines to modify no-specifier requirements, so nil here is expected input, not a resolution failure — a no-op keeps the file byte-identical and matches the existing nil-guard in the pip-compile updater.
  • The guard lives at the single shared call site, so one change covers both the pip and uv code paths (uv aliases the Python RequirementFileUpdater).
  • No "No files have changed!" regression on the real path. The crash reaches the shared updater through the pip-compile flow, where the regenerated lockfile is always part of the result set. Skipping a specifier-less input therefore still yields a non-empty change set, so the top-level updater does not raise. The skip only ever produces an empty result in the pre-existing, unrelated case where a specifier-less requirement is the sole change with no lockfile present — behavior that is unchanged by this PR.

How will you know you've accomplished your goal?

  • New regression specs reproduce no-specifier shapes (bare name and a URL/VCS reference) for both the pip and uv paths; they previously raised and now pass with the file left unchanged.
  • Existing Python and uv requirement file updater suites remain green.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Copilot AI balanced review requested due to automatic review settings September 17, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The guard safely handles valid nil requirements, and both shared consumer paths have focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents Python and uv requirement updates from crashing when a dependency has no version specifier.

Changes:

  • Skips rewriting requirements with a nil specifier.
  • Adds bare-name and direct-reference regression coverage for Python and uv.
File Description
python/​lib/​dependabot/​python/​file_updater/​requirement_file_updater.rb Adds the no-op guard.
python/​spec/​dependabot/​python/​file_updater/​requirement_file_updater_spec.rb Covers Python requirements without specifiers.
uv/​spec/​dependabot/​uv/​file_updater/​requirement_file_updater_spec.rb Covers the shared updater through uv.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@v-kbukum1
v-kbukum1 marked this pull request as ready for review September 17, 2026 05:01
@v-kbukum1
v-kbukum1 requested a review from a team as a code owner September 17, 2026 05:01
…nt file updater

A version specifier is optional per PEP 508 and the pip requirements format
(bare names, URL/VCS/editable/local-path references, unpinned pip-tools inputs,
PEP 621 / [tool.uv.sources]). The requirement file updater assumed every
requirement carried one and crashed with a TypeError when it did not.

Guard the nil at the single shared call site so a no-specifier requirement is
left unchanged instead of forced through the replacer, matching the existing
pip-compile nil-guard. uv reuses this updater, so the fix covers pip and uv.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 18, 2026 15:53
@v-kbukum1
v-kbukum1 force-pushed the kbukum1/python-uv-requirement-no-version-specifier branch from a0d2340 to 12e4de8 Compare September 18, 2026 15:53

This comment was marked as resolved.

@v-kbukum1
v-kbukum1 merged commit d71b123 into main Sep 18, 2026
252 of 255 checks passed
@v-kbukum1
v-kbukum1 deleted the kbukum1/python-uv-requirement-no-version-specifier branch September 18, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants