fix error of removing packages if nested groups (include-group) are used in pep735 style#10587
Merged
radoering merged 4 commits intopython-poetry:mainfrom Oct 26, 2025
Conversation
Reviewer's GuideFix removal errors when nested include-group constructs are used by filtering out non-string requirement entries in the remove command logic and add parameterized tests covering both PEP 735 and legacy group syntax to verify proper pyproject updates. Class diagram for updated remove command logicclassDiagram
class RemoveCommand {
+handle() int
-_remove_packages(packages, standard_section, poetry_section)
}
class Dependency {
+create_from_pep_508(requirement)
+name
}
RemoveCommand --> Dependency: uses
Flow diagram for package removal with nested include-group constructsflowchart TD
A["Start package removal"] --> B["Read pyproject content"]
B --> C["Get dependency groups and poetry groups"]
C --> D["Iterate over packages to remove"]
D --> E["For each requirement in standard section"]
E --> F{Is requirement a string?}
F -- Yes --> G["Check if requirement name matches package"]
G -- Match --> H["Remove requirement"]
G -- No match --> I["Continue"]
F -- No --> I
H --> J["Add package to removed set"]
I --> D
J --> D
D --> K["Finish"]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `tests/console/commands/test_remove.py:739-691` </location>
<code_context>
+ pyproject = app.poetry.file.read()
+ pyproject = cast("dict[str, Any]", pyproject)
+ content = pyproject["tool"]["poetry"]
+ assert "foo" not in content["dependencies"]
+
+ if pep_735:
+ assert "bar" not in pyproject["dependency-groups"]
+ assert any("baz" in dep for dep in pyproject["dependency-groups"]["foobar"])
</code_context>
<issue_to_address>
**suggestion (testing):** Test could be improved by verifying side effects on installed packages.
Please add an assertion to confirm that 'foo' is removed from the 'installed' repository after the operation.
Suggested implementation:
```python
pyproject = app.poetry.file.read()
pyproject = cast("dict[str, Any]", pyproject)
content = pyproject["tool"]["poetry"]
assert "foo" not in content["dependencies"]
# Assert 'foo' is not present in the installed repository
installed_packages = [pkg.name for pkg in app.poetry.repository.installed()]
assert "foo" not in installed_packages
```
If `app.poetry.repository.installed()` does not exist or uses a different API, you may need to adjust the method to retrieve the list of installed packages according to your Poetry test setup.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
radoering
reviewed
Oct 19, 2025
…sed in pep735 style
… whole group when it's empty even if it contains nested group
… whole group when it's empty even if it contains nested group
887fb04 to
3d9a787
Compare
radoering
approved these changes
Oct 26, 2025
|
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. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull Request Check List
Resolves: #10586
Tests: