Skip to content

fix poetry update <dep> where <dep> is a transitive dependency - #10885

Merged
radoering merged 1 commit into
python-poetry:mainfrom
radoering:fix-update-transitive-dep
May 8, 2026
Merged

radoering merged 1 commit into
python-poetry:mainfrom
radoering:fix-update-transitive-dep

Conversation

@radoering

@radoering radoering commented May 8, 2026 •

Copy link
Copy Markdown
Member

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

#10721 broke poetry update <dep> in cases where <dep> is not declared in pyproject.toml but only a transitive dependency. This PR fixes the regression.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • When building all_dependencies, consider canonicalizing the names from locked_repository().packages (e.g. via canonicalize_name) so that the membership check against canonicalize_name(p) is case/normalization-robust for both declared and locked dependencies.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When building `all_dependencies`, consider canonicalizing the names from `locked_repository().packages` (e.g. via `canonicalize_name`) so that the membership check against `canonicalize_name(p)` is case/normalization-robust for both declared and locked dependencies.

## Individual Comments

### Comment 1
<location path="src/poetry/console/commands/update.py" line_range="76-78" />
<code_context>
+            #     pyproject where the lockfile has not caught up yet)
+            #   - locked deps in poetry.lock (covers transitive deps that
+            #     are not declared directly in pyproject.toml)
             all_dependencies = {dep.name for dep in self.poetry.package.all_requires}
+            all_dependencies |= {
+                p.name for p in self.poetry.locker.locked_repository().packages
+            }

</code_context>
<issue_to_address>
**issue (bug_risk):** Align dependency names with `canonicalize_name` to avoid mismatches for normalized package names.

`invalid_packages` uses `canonicalize_name(p)` for user input, but `all_dependencies` uses raw `dep.name` / `p.name`. If those aren’t already normalized the same way (dashes vs underscores, case), valid packages may be flagged as invalid. Consider building `all_dependencies` from `canonicalize_name(dep.name)` and `canonicalize_name(p.name)` so both sides of the comparison are normalized consistently.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/poetry/console/commands/update.py
@radoering
radoering force-pushed the fix-update-transitive-dep branch from ee811fb to dfc37d2 Compare May 8, 2026 15:03
@radoering
radoering merged commit 409c83c into python-poetry:main May 8, 2026
54 checks passed
mwalbeck pushed a commit to mwalbeck/docker-python-poetry that referenced this pull request May 24, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [poetry](https://github.com/python-poetry/poetry) ([changelog](https://python-poetry.org/history/)) | patch | `2.4.0` → `2.4.1` |

---

### Release Notes

<details>
<summary>python-poetry/poetry (poetry)</summary>

### [`v2.4.1`](https://github.com/python-poetry/poetry/blob/HEAD/CHANGELOG.md#241---2026-05-09)

[Compare Source](python-poetry/poetry@2.4.0...2.4.1)

##### Changed

- Re-allow `installer==0.7.0` ([#&#8203;10887](python-poetry/poetry#10887)).

##### Fixed

- Fix an issue where `poetry update <package>` failed when `<package>` was a transitive dependency ([#&#8203;10885](python-poetry/poetry#10885)).

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzAuMTkiLCJ1cGRhdGVkSW5WZXIiOiI0My4xNzAuMTkiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://git.walbeck.it/mwalbeck/docker-python-poetry/pulls/1744
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 8, 2026
@radoering
radoering deleted the fix-update-transitive-dep branch August 22, 2026 04:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants