Skip to content

fix(show): report stale lock files clearly - #11010

Open
AG0708 wants to merge 1 commit into
python-poetry:mainfrom
AG0708:codex/9485-stale-show-lock-error
Open

fix(show): report stale lock files clearly#11010
AG0708 wants to merge 1 commit into
python-poetry:mainfrom
AG0708:codex/9485-stale-show-lock-error

Conversation

@AG0708

@AG0708 AG0708 commented Aug 12, 2026

Copy link
Copy Markdown

Pull Request Check List

Resolves: #9485

  • Added tests for changed code.
  • Updated documentation for changed code. Not applicable; this corrects an existing CLI error path.

Summary

When poetry show tries to solve against a stale lock file, the solver can currently emit a misleading dependency-resolution failure such as:

Because test depends on basedmypy (2.4.0) which does not match any versions, version solving failed.

This change detects that specific combination—a stale lock followed by SolverProblemError—and reports Poetry's canonical recovery guidance instead:

Error: pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock` to fix the lock file.

Fresh-lock solver failures and successful stale-lock show paths remain unchanged.

Validation

  • Real CLI reproduction against the existing outdated_lock fixture.
  • Regular and self show suites: 90 passed.
  • Ruff, mypy, all changed-file pre-commit hooks, and Git whitespace checks passed.

AI assistance is disclosed in the commit trailer.

When show resolves packages against a stale lock, the solver can report that dependencies match no versions. Detect that combination and direct users to regenerate the lock file while preserving solver errors for fresh locks.

Fixes python-poetry#9485.

Signed-off-by: Abhinav Gorrepati <gorrepatiabhinav1@gmail.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new stale-lock error message logic duplicates existing guidance strings; consider centralizing this message (and the self._lock_create_command() usage) in a shared helper to avoid future divergence.
  • Returning 1 from _display_packages_information on stale-lock errors changes its return-type behavior; confirm callers either ignore the return value or adjust the method to use a more consistent error-signaling pattern (e.g. raising a specific exception).
  • The bare except SolverProblemError will intercept all solver issues during show; if there are non-lock-related solver failures that should surface differently, consider checking for locker.is_fresh() before catching or rewrapping the exception to preserve more context.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new stale-lock error message logic duplicates existing guidance strings; consider centralizing this message (and the `self._lock_create_command()` usage) in a shared helper to avoid future divergence.
- Returning `1` from `_display_packages_information` on stale-lock errors changes its return-type behavior; confirm callers either ignore the return value or adjust the method to use a more consistent error-signaling pattern (e.g. raising a specific exception).
- The bare `except SolverProblemError` will intercept all solver issues during `show`; if there are non-lock-related solver failures that should surface differently, consider checking for `locker.is_fresh()` before catching or rewrapping the exception to preserve more context.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(🐞) Confusing error message in poetry show with outdated lock file

1 participant