Repository navigation
fix(poetry): handle multi-constraint lockfile deps - #1157
Draft
evan-mercer-dev wants to merge 1 commit into
Draft
evan-mercer-dev wants to merge 1 commit into
evan-mercer-dev wants to merge 1 commit into
Conversation
Normalize `[package.dependencies]` entries in `poetry.lock` to a list of dependency spec dicts via `PoetryBB._normalize_dep_specs()`, matching how `_make_bom()` normalizes multi-constraint declarations in `pyproject.toml` (CycloneDX#842). In `__add_dep()`, skip a locked dependency when all of its constraint entries are marked `optional = true`, and propagate `extras` across all constraint entries to each matching lock entry. Fixes CycloneDX#1151 Signed-off-by: Evan Mercer <356857887+evan-mercer-dev@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 7 (≤ 20 complexity) |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
1 of 2 tasks
jkowalleck
marked this pull request as draft
November 26, 2026 16:36
Member
|
not accepting a fix unless the report was triaged. |
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.
Description
When
poetry.lockcontains a multi-constraint dependency entry (list[dict]) under[package.dependencies](written by Poetry whenever a locked package has marker-split constraints on the same dependency),PoetryBB._parse_lock()previously wrapped the list as{'version': [...]}instead of normalizing it to a list of dependency spec mappings. As a result,PoetryBB.__add_dep():dep_spec.get('optional')asNoneeven when every constraint in the list hadoptional = true, including uninstalled optional transitive packages in the SBOM when the corresponding extra was not enabled.dep_spec.get('extras', ())as(), dropping transitive extras and omittingcdx:python:package:required-extraproperties and extra dependencies from the SBOM.This change extracts
PoetryBB._normalize_dep_specs()to normalizestr | dict | listdependency declarations intolist[T_NameDict]across both_make_bom()and_parse_lock()(aligning lockfile parsing with#842), skips transitive dependencies in__add_dep()when all constraint entries haveoptional = true, and aggregatesextrasacross all constraint entries into a reusable tuple passed to each matching lock entry.Unit and CLI regression tests are added in
tests/unit/test_poetry.pycovering all-optional exclusion when unused, inclusion when the parent extra is enabled, mixed optional/non-optional constraints, and transitiveextraspropagation across multi-version lock entries.Resolves or fixes issue: #1151
AI Tool Disclosure
Gemini CLIGemini 2.5 ProTrace how PoetryBB._make_bom (#842) normalizes multi-constraint dependency entries vs PoetryBB._parse_lock / __add_dep for #1151, implement symmetric list[T_NameDict] normalization, and add unit regression tests verifying optional filtering and transitive extras propagation.Affirmation