poetry
poetry copied to clipboard
cli: suggest poetry self lock for self subcommands (#10536)
- Add lock_command_hint_for() to choose hint by lockfile location (CONFIG_DIR → poetry self lock, else poetry lock).
- Use in installer (stale lock), show (missing lock), and check (stale lock).
Motivation
- Avoids suggesting poetry lock for poetry self … commands (fixes confusion in #10536).
Tests
- tests/installation/test_installer.py::test_not_fresh_lock_in_self_context_suggests_self_lock
- tests/console/commands/self/test_show.py::test_self_show_errors_without_lock_file
Compatibility
- Project commands still suggest poetry lock.
Resolves: #10536
Pull Request Check List
- [x] Added tests for changed code.
- [ ] Updated documentation for changed code. (N/A)
Summary by Sourcery
Improve lock-related error messages by detecting when commands are running in Poetry’s own configuration directory and suggesting poetry self lock instead of poetry lock where applicable
New Features:
- Introduce lock_command_hint_for helper to choose between
poetry lockandpoetry self lockbased on lockfile location - Integrate lock_command_hint_for into show, check, and installer commands to suggest the appropriate lock command
Tests:
- Add test verifying
poetry self locksuggestion when lock is stale in self context installer - Add test verifying missing lock file error suggests
poetry self lockin show command
Reviewer's Guide
Introduces a helper to choose between poetry self lock and poetry lock based on the lockfile location, and updates the show, check, and installer commands to use this dynamic hint in their error messages, with new tests verifying the behavior in self contexts.
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Helper for dynamic lock command hints |
|
src/poetry/utils/helpers.py |
| Use dynamic hints in CLI commands |
|
src/poetry/console/commands/show.pysrc/poetry/console/commands/check.pysrc/poetry/installation/installer.py |
| Add tests for self subcommands |
|
tests/console/commands/self/test_show.pytests/installation/test_installer.py |
Possibly linked issues
-
#10536: PR introduces
lock_command_hint_forto suggestpoetry self lockfor self subcommands, fixing the incorrect hint. -
#10536: The PR clarifies
selfcommand behavior by suggestingpoetry self lockfor Poetry's own project, addressing confusion related to issue #10536.
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
-
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. -
Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.