fix: suggest poetry self lock for self commands#10715
fix: suggest poetry self lock for self commands#10715radoering merged 6 commits intopython-poetry:mainfrom
poetry self lock for self commands#10715Conversation
Reviewer's GuideAdjusts the installer’s outdated-lock error message to suggest Sequence diagram for Installer lock fix command selectionsequenceDiagram
actor User
participant CLI as Poetry_CLI
participant Installer
User->>CLI: run "poetry install" (or "poetry self install")
CLI->>Installer: create Installer with Package
CLI->>Installer: run()
Installer->>Installer: _do_install()
Installer->>Locker: is_locked()
Locker-->>Installer: bool
Installer->>Locker: is_fresh()
Locker-->>Installer: bool (False when lock outdated)
Installer->>Installer: _lock_fix_command()
alt system project (package.name == poetry-instance)
Installer-->>Installer: returns "poetry self lock"
else regular project
Installer-->>Installer: returns "poetry lock"
end
Installer-->>CLI: raise ValueError with suggested command
CLI-->>User: displays error with appropriate lock command suggestion
Class diagram for updated Installer lock suggestion logicclassDiagram
class Installer {
- Package _package
- Locker _locker
- bool _update
- bool _lock
+ set_locker(locker: Locker) Installer
+ run() int
- _do_install() int
- _lock_fix_command() str
}
class Package {
+ name: str
}
class Locker {
+ is_locked() bool
+ is_fresh() bool
+ is_locked_groups_and_markers() bool
}
Installer --> Package : uses
Installer --> Locker : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Using the magic string "poetry-instance" in
_lock_fix_commandtightly couples behavior to a specific package name; consider centralizing this in a constant or a helper that more explicitly identifies the system/self project to avoid brittle coupling if the name ever changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using the magic string "poetry-instance" in `_lock_fix_command` tightly couples behavior to a specific package name; consider centralizing this in a constant or a helper that more explicitly identifies the system/self project to avoid brittle coupling if the name ever changes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Good point — updated to avoid the magic string by centralizing the system project name as a constant on |
|
Please make sure that the CI does not fail. (PRs that pass the CI are more likely to be reviewed. This also applies to your other PRs.) |
|
Good call. I’ll rebase and fix the failing CI jobs on this PR (and clean up the other open Poetry PRs as well) before requesting more review. |
radoering
left a comment
There was a problem hiding this comment.
I think I like the approach of using the project name compared to the file location approach from the previous (stalled) PR #10568. However, this PR does not consider poetry self show, which the stalled PR did. Can you please also handle poetry self show?
|
Quick follow-up: acknowledged on CI quality. I’ll post an update on this PR after I rebase and get all required checks green, then request another review. |
bd19ef1 to
c6671a0
Compare
|
Thanks for the review — I pushed an update to also handle What changed:
Validation:
Could you please take another look? |
|
Follow-up pushed to fix the failing
Could you please re-check when CI completes? |
|
Follow-up update: branch is rebased, the constant is centralized, and all required checks are green now. Could you take another look when you have time? |
38d02e4 to
3aba07b
Compare
poetry self lock for self commands
poetry self lock for self commandspoetry self lock for self commands
|
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. |
Fixes #10536.
When an install/sync operation is run via
poetry self ..., the outdated-lock message currently suggestspoetry lock, which points at the current project rather than Poetry’s system project.This changes the suggestion to
poetry self lockwhen the installer is operating on Poetry’s system project.Tests:
python -m pytest -o addopts= tests/installation/test_installer.py::test_not_fresh_lock_self_projectSummary by Sourcery
Adjust installer lock-file guidance to suggest the appropriate command when working on Poetry’s own system project.
Bug Fixes:
poetry self lockinstead ofpoetry lock.Tests:
poetry self lockwhen the lock file is not fresh.