Repository navigation
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/poetry/console/commands/remove.py" line_range="246" />
<code_context>
for group_key in groups_to_remove:
del content["dependency-groups"][group_key]
+ removed_groups.add(group_key)
# 2. Legacy: [tool.poetry.group.<name>] include-groups = [...]
</code_context>
<issue_to_address>
**Unrelated groups are deleted**
When reference cleanup encounters a pre-existing empty PEP 735 group or a legacy group with an empty `include-groups` list, `groups_to_remove` includes groups even when this cleanup removed none of their entries. Adding them to `removed_groups` makes recursive reference cleanup delete groups that include them, so unrelated group declarations disappear.
Add a group to `removed_groups` only when this cleanup made it empty.
Also at `src/poetry/console/commands/remove.py:267`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the recursive cleanup removes a group that still contains meaningful configuration, that group and its dependency declarations are deleted from the project file, and the regenerated lock can drop those packages. Reverting the code does not restore the edited project file or lock; they would need to be recovered or rebuilt.
Blocking findings: src/poetry/console/commands/remove.py:246
|
I investigated the Ubuntu/Python 3.11 CI failure and reproduced it on both unchanged base The failing test globally mocks With the CI seed, the added tests shift xdist's initial batch boundary, making this case the first test on its worker. Replaying the base's preceding tests passes on both revisions. The complete installer module also passes all 460 cases on both. This appears to be a pre-existing test-isolation defect exposed by the changed worker assignment. I've left the group-cleanup implementation unchanged. Would you prefer the test correction handled separately or included here? Reproduction commands and full tracebacks are preserved. |
radoering
left a comment
There was a problem hiding this comment.
Can you rebase your branch please? (tomlkit has been replaced with tomlrt so that you have to adapt the tests.)
Preserve section tables when reversing group declarations, move complex cleanup tests after the basic cases, and number the recursive cleanup section.
7f81db5 to
b8581f1
Compare
|
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. |
Resolves: #11140
Related to #10590 and the direct-reference cleanup in #10653.
When
toolsincludeslintanddevincludestools, removing the last dependency fromlintsucceeds but leavesdevreferring to the deletedtoolsgroup. The next project command then fails becausetoolsis undefined.This change recursively cleans references to groups deleted by reference cleanup. A group is deleted only when removing a matching inclusion made it empty. Pre-existing empty groups and their parents survive, as do references to groups still defined in the other TOML section.
The regression tests cover chains and a diamond with shared parents, both declaration orders, explicit/all-group removal, PEP 735/legacy/mixed declarations, retained cross-section definitions, and unrelated empty groups and their parents. They check remaining TOML structure, project reload, remaining requirements, locked packages, and lock freshness.
Review follow-up
mainatb1e370bf.tomlrt.loads/tomlrt.dumps. Reversed declarations use explicit section tables, preserving valid legacy TOML sections.Validation at
b8581f12Ubuntu 24.04, official setup-python CPython 3.11.17 artifact, committed locked dependencies:
Before migration: 12 obsolete-API failures and 3 passes in the focused cases. After migration: all 15 focused cases pass.
Complete remove-command suite: 40 passed.
Console-command suite: 881 passed, 6 standard skips.
Full mypy: 380 files passed.
All applicable pinned pre-commit hooks on both changed files, including Ruff lint/format, and
git diff --check: passed.Full default suite, non-root user with compiler prerequisites: 3,332 passed, 34 standard skips, 2 expected failures. Fresh upstream base with the same environment and seed: 3,317 passed, the same 34 skips and 2 expected failures. Initial container failures from PATH, missing GCC and root permission bypass were corrected in the environment only; no tests were weakened or newly skipped.
Fresh upstream CI completed successfully: 47 jobs passed and 3 were skipped by workflow conditions, including a passing Ubuntu/Python 3.11 pytest job. Sourcery and pre-commit.ci also passed. No review approval is implied.
Pull Request Check List
AI assistance: OpenAI Codex was used for investigation, implementation, regression tests, rebase, and validation. No human code review is claimed.