-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix error of removing packages if nested groups (include-group) are used in pep735 style #10587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix error of removing packages if nested groups (include-group) are used in pep735 style #10587
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
…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
|
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. |
Pull Request Check List
Resolves: #10586
Tests: