-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(application): handle global options correctly #10021
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
Conversation
Reviewer's Guide by SourceryThis pull request fixes a bug where global options were not handled correctly when positioned after command options, leading to incorrect cached working directory values. The fix involves refactoring the Application class to correctly handle global options such as Sequence diagram for global options handling in ApplicationsequenceDiagram
participant App as Application
participant IO as IO
participant Dir as Directory Utils
App->>App: _run(io)
App->>App: _configure_custom_application_options(io)
App->>IO: Get option values (directory, project)
App->>Dir: ensure_path(directory)
Note right of Dir: Validate directory path
Dir-->>App: Return validated working_directory
App->>Dir: ensure_path(project)
Note right of Dir: Validate project path
Dir-->>App: Return validated project_directory
Class diagram showing Application class changesclassDiagram
class Application {
-_working_directory: Path
-_project_directory: Path
-_disable_plugins: bool
-_disable_cache: bool
+_run(io: IO): int
+_configure_custom_application_options(io: IO): void
+_option_get_value(io: IO, name: str, default: Any): Any
}
class Helpers {
+ensure_path(path: str|Path, is_directory: bool): Path
}
Application ..> Helpers: uses
Flow diagram for global options processingflowchart TD
A[Start] --> B[Get IO input]
B --> C{Has directory option?}
C -->|Yes| D[Validate directory path]
C -->|No| E[Use current directory]
D --> F{Has project option?}
E --> F
F -->|Yes| G[Validate project path]
F -->|No| H[Use working directory]
G --> I[Set working and project directories]
H --> I
I --> J[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The issue reported in #9978 can be reproduced and the fix in this PR tested using the following snippet. podman run --rm -i --entrypoint bash python:latest <<EOF
set -x
python -m pip install --disable-pip-version-check --root-user-action ignore -q poetry
pushd /tmp
poetry new foobar
poetry add -C /tmp/foobar httpx
poetry show --only main -C /tmp/foobar || :
python -m pip install --disable-pip-version-check --root-user-action ignore -q --force 'git+https://github.com/python-poetry/poetry.git@refs/pull/10021/head'
poetry show --only main -C /tmp/foobar
EOF |
There was a problem hiding this 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 and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
af98156
to
49a09b2
Compare
@sourcery-ai review |
There was a problem hiding this 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 and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
89b3d62
to
2cc721c
Compare
Previously, the application implementation did not handle global options correctly when positioned after command options. This lead to incorrect cached working directory values prior to switching application context. Resolves: python-poetry#9978
Changed the path resolution for |
This change ensures that context options like --project and --directory are validated prior to executing the application to prevent runtime exceptions.
This change fixes an issue introduced in python-poetry#10021 that led to options provided in the form `-<shortcut><value>` to be incorrectly handled. Further, it also simplifies and fixes run command processing. Resolves: python-poetry#10051
This change fixes an issue introduced in python-poetry#10021 that led to options provided in the form `-<shortcut><value>` to be incorrectly handled. Further, it also simplifies and fixes run command processing. Resolves: python-poetry#10051
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. |
Previously, the application implementation did not handle global options correctly when positioned after command options. This lead to incorrect cached working directory values prior to switching application context.
Resolves: #9978 python-poetry/poetry-plugin-shell#5
Summary by Sourcery
Bug Fixes: