Skip to content

Comments

Show Python path for Poetry in debug info#10588

Merged
radoering merged 3 commits intopython-poetry:mainfrom
jaredahern:main
Nov 24, 2025
Merged

Show Python path for Poetry in debug info#10588
radoering merged 3 commits intopython-poetry:mainfrom
jaredahern:main

Conversation

@jaredahern
Copy link
Contributor

@jaredahern jaredahern commented Oct 19, 2025

Pull Request Check List

Resolves: #10559

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary

Adds the executable and environment path for the Python executable running Poetry to poetry self debug.

I believe the sys calls are correct, but happy to adjust as needed. Also, I did not see any docs that required updating.

Summary by Sourcery

Include the Python environment path and executable in the output of poetry self debug.

Enhancements:

  • Add 'Path' and 'Executable' fields under the Poetry section in debug info
  • Adjust label alignment for Version and Python fields

Tests:

  • Add tests to verify the display of Poetry's path and executable in debug info

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 19, 2025

Reviewer's Guide

Extends the poetry self debug info command to include the Poetry interpreter’s environment path and executable (using sys.prefix and sys.executable), updates output alignment, and adds tests verifying the enhanced debug output.

Sequence diagram for enhanced debug info output in handle()

sequenceDiagram
    participant User as actor User
    participant DebugInfoCommand
    participant sys
    participant Poetry
    User->>DebugInfoCommand: invoke handle()
    DebugInfoCommand->>Poetry: get VERSION
    DebugInfoCommand->>sys: get python version
    DebugInfoCommand->>sys: get prefix (env path)
    DebugInfoCommand->>sys: get executable
    DebugInfoCommand-->>User: print debug info (Version, Python, Path, Executable)
Loading

Class diagram for updated DebugInfoCommand output

classDiagram
    class DebugInfoCommand {
        +handle() int
        -poetry: Poetry
    }
    class Poetry {
        +VERSION: str
    }
    DebugInfoCommand --> Poetry: uses
    %% Updated output attributes in handle()
    %% Now includes Version, Python, Path, Executable
Loading

File-Level Changes

Change Details Files
Extend debug info output to include environment path and executable
  • Adjusted spacing for Version and Python lines
  • Introduced Path line using sys.prefix
  • Introduced Executable line using sys.executable with fallback
src/poetry/console/commands/debug/info.py
Add tests covering new debug info fields
  • Mocked EnvManager.get, sys.prefix, and sys.executable fixtures
  • Added test to execute debug info and assert complete output
tests/console/commands/debug/test_info.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on 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 issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on 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 dismiss on 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 review to 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

Copy link

@sourcery-ai sourcery-ai bot left a 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/debug/test_info.py:18` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Don't import test modules. ([`dont-import-test-modules`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/dont-import-test-modules))

<details><summary>Explanation</summary>Don't import test modules.

Tests should be self-contained and don't depend on each other.

If a helper function is used by multiple tests,
define it in a helper module,
instead of importing one test from the other.
</details>
</issue_to_address>

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.

Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

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

LGTM except for the failing Windows tests. Can you take a look, please?

@jaredahern
Copy link
Contributor Author

jaredahern commented Nov 24, 2025

Hmm. I took a look at the errors, and tried to resolve them. Not sure if I totally have. Here's the original error:

    Poetry
    Version:    2.2.1
    Python:     3.10.11
    Path:       /poetry/prefix
    Executable: /poetry/prefix/bin/python

    Virtualenv
    Python:         3.7.0
    Implementation: CPython
    Path:           \prefix
  - Executable:     /poetry/prefix/bin/python
  ?                 ^      ^      ^   ^
  + Executable:     \poetry\prefix\bin\python
  ?                 ^      ^      ^   ^
    Valid:          True

    Base
    Platform:   darwin
    OS:         posix
    Python:     3.10.11
    Path:       \base\prefix
    Executable: python

So here, the error appears to be with the output from the env info command, which I haven't touched, and directly copied the test for. It confuses me that the related test_env_info_displays_complete_info test does not fail.

That being said, I tried to be more careful with paths, to better support Windows. Happy to take pointers. I rebased onto main and added a commit. There are now different failing tests, which seem to be unrelated to the changes here. Any thoughts on how I should proceed?

@radoering
Copy link
Member

So here, the error appears to be with the output from the env info command, which I haven't touched, and directly copied the test for. It confuses me that the related test_env_info_displays_complete_info test does not fail.

You mock sys.executable in the new test. Your mock uses forward slashes on Windows. test_env_info_displays_complete_info just uses the real sys.executable, which has backslashes.

There are now different failing tests, which seem to be unrelated to the changes here. Any thoughts on how I should proceed?

Just wait and re-run. That was actions/runner-images#13341

@radoering radoering merged commit 9e1062a into python-poetry:main Nov 24, 2025
63 checks passed
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show path to poetry self venv python

2 participants