Skip to content
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(ux): improve command not found errors #10127

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

abn
Copy link
Member

@abn abn commented Jan 29, 2025

fix(ux): improve namespace command not found error

Resolves: #10123

image

fix(ux): improve command not found error

Screenshot From 2025-01-30 01-40-12

Screenshot From 2025-01-30 01-40-24

Screenshot From 2025-01-30 01-40-34

Summary by Sourcery

Bug Fixes:

  • Fix: Command not found error within a namespace now provides helpful suggestions and documentation links.

@abn abn added the area/error-handling Bad error messages/insufficient error handling label Jan 29, 2025
@abn abn requested a review from a team January 29, 2025 23:51
Copy link

sourcery-ai bot commented Jan 29, 2025

Reviewer's Guide by Sourcery

This pull request improves the error message when a user attempts to use a command that does not exist within a namespace. Instead of a generic command not found error, the user will now see a more specific error message that indicates the command does not exist in the given namespace, along with a list of suggested commands and a link to the documentation.

Sequence diagram for improved namespace command error handling

sequenceDiagram
    actor User
    participant App as Poetry Application
    participant IO as IO Interface

    User->>App: Execute command
    App->>App: Check command exists
    alt Command not found but namespace exists
        App->>App: Get sub-commands in namespace
        App->>App: Find similar command names
        App->>IO: Write error with suggestions
        App->>IO: Write documentation link
        IO-->>User: Display error message
    else Other error
        App->>App: Raise original error
    end
Loading

File-Level Changes

Change Details Files
Improve error message for commands not found within a namespace.
  • Added a check to see if the command is a namespace.
  • If the command is a namespace, generate a list of subcommands.
  • Suggest similar commands to the user.
  • Output a more specific error message to the user.
  • Include a link to the documentation for the namespace.
src/poetry/console/application.py
Add tests for the new error message.
  • Added a new test case to verify the new error message.
  • Added a parameterization to test multiple namespaces.
tests/console/test_application_removed_commands.py

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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 @abn - I've reviewed your changes - here's some feedback:

Overall Comments:

  • There's a grammatical error in the error message: "does not exists" should be "does not exist"
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

src/poetry/console/application.py Outdated Show resolved Hide resolved
tests/console/test_application_removed_commands.py Outdated Show resolved Hide resolved
@abn abn enabled auto-merge (squash) January 30, 2025 00:06
@abn abn force-pushed the ux/improve-namespace-error branch from 6212c6e to d682590 Compare January 30, 2025 00:15
@abn abn disabled auto-merge January 30, 2025 00:39
@abn abn force-pushed the ux/improve-namespace-error branch from 77a8fd7 to 9dced99 Compare January 30, 2025 00:48
@abn abn changed the title fix(ux): improve namespace command not found error fix(ux): improve command not found errors Jan 30, 2025
@abn abn added the area/ux Features and improvements related to the user experience label Jan 30, 2025
@abn abn force-pushed the ux/improve-namespace-error branch from 9dced99 to c7d93a3 Compare January 30, 2025 17:12
@abn abn merged commit 0bb0e91 into python-poetry:main Jan 31, 2025
53 checks passed
@abn abn deleted the ux/improve-namespace-error branch January 31, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/error-handling Bad error messages/insufficient error handling area/ux Features and improvements related to the user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error message says env command does not exist when misspelling env remove as env remote
2 participants