Merged
Conversation
f354f7a to
efd9e57
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Dependabot’s Poetry handling for PEP 621 dynamic dependency fields to avoid parsing/updating dependencies that are managed dynamically by Poetry, and refactors/strengthens related update logic and regex handling.
Changes:
- Skip PEP 621
dependencies/optional-dependenciesparsing when those fields are marked dynamic and Poetry is the backend. - Refactor
PyprojectPreparerregex usage and freezing logic to avoid interpolated patterns and reduce complexity. - Adjust PEP 508 specifier rewriting logic used by the Poetry PEP 621 updater; add fixtures/specs for dynamic cases.
Show a summary per file
| File | Description |
|---|---|
| python/spec/fixtures/pyproject_files/pep621_dynamic_optional_dependencies.toml | Adds a fixture covering dynamic optional-dependencies in a Poetry-backed project. |
| python/spec/fixtures/pyproject_files/pep621_dynamic_dependencies.toml | Adds a fixture for dynamic dependencies in a Poetry-backed project. |
| python/spec/dependabot/python/file_parser/pyproject_files_parser_spec.rb | Adds specs asserting dynamic PEP 621 dependency fields are skipped for Poetry. |
| python/lib/dependabot/python/file_updater/pyproject_preparer.rb | Replaces interpolated regex patterns with a fixed prefix regex and normalised name matching; refactors freezing logic. |
| python/lib/dependabot/python/file_updater/poetry_file_updater/pep621_updater.rb | Changes how PEP 508 specifier versions are rewritten to better handle reordering. |
| python/lib/dependabot/python/file_parser/pyproject_files_parser.rb | Implements dynamic-field-based skipping of PEP 621 dependency parsing when using Poetry. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 3
…rser and add corresponding tests
…r.rb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ests for dynamic dependencies
…elds handling and improve version replacement logic
990045a to
096a667
Compare
markhallen
previously approved these changes
Apr 15, 2026
markhallen
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
When a Poetry
pyproject.tomllistsdependenciesoroptional-dependenciesin[project].dynamic, those are managed by Poetry, not statically declared. Dependabot was parsing them from[project]anyway, creating duplicates and updating the wrong location. This PR skips dynamic PEP 621 dependencies when Poetry is the build backend.Additionally fixes two CodeQL polynomial-regex alerts in
PyprojectPreparerby replacing interpolated name patterns with a fixedPEP508_PREFIXconstant andNameNormaliser-based matching. Also refactorsfreeze_top_level_dependencies_exceptinto smaller helpers, extracts aPep621UpdaterfromPoetryFileUpdater, and fixesBumpVersionsstrategy for range requirements.Anything you want to highlight for special attention from reviewers?
The regex refactoring in
pyproject_preparer.rbaddresses CodeQL polynomial backtracking alerts.pin_pep508_entrysignature changed from(entry, name_pattern, version)to(entry, version)— it uses a fixed regex instead of interpolating dependency names. Name matching now usesNameNormaliser.normalise()comparison instead of dynamic regex patterns.How will you know you've accomplished your goal?
Poetry projects with
dynamic = ["dependencies"]ordynamic = ["optional-dependencies"]in[project]will no longer produce duplicate dependencies or attempt PEP 621 updates for Poetry-managed deps. Range requirements like>=1.0,<2.0are correctly bumped under theBumpVersionsstrategy.Checklist