perf: skip plugin loading for version requests#10902
Open
Sean-Kenneth-Doherty wants to merge 1 commit into
Open
perf: skip plugin loading for version requests#10902Sean-Kenneth-Doherty wants to merge 1 commit into
Sean-Kenneth-Doherty wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Overloading
_disable_pluginsto also cover--version/-Vmakes the flag semantics less clear; consider introducing a separate local variable or helper (e.g._should_load_plugins(io)) so that skipping plugins for version requests is explicit and easier to reason about. - The
has_parameter_optioncall now takes a list of options; if there are other global options that should also bypass plugin loading in the future, consider centralizing the list (e.g. a constant or method) so it doesn’t become scattered magic values.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Overloading `_disable_plugins` to also cover `--version`/`-V` makes the flag semantics less clear; consider introducing a separate local variable or helper (e.g. `_should_load_plugins(io)`) so that skipping plugins for version requests is explicit and easier to reason about.
- The `has_parameter_option` call now takes a list of options; if there are other global options that should also bypass plugin loading in the future, consider centralizing the list (e.g. a constant or method) so it doesn’t become scattered magic values.
## Individual Comments
### Comment 1
<location path="src/poetry/console/application.py" line_range="627-628" />
<code_context>
return
- self._disable_plugins = io.input.has_parameter_option("--no-plugins")
+ self._disable_plugins = io.input.has_parameter_option(
+ ["--no-plugins", "--version", "-V"], only_params=True
+ )
</code_context>
<issue_to_address>
**issue:** Using `only_params=True` changes how `--no-plugins` behaves after `--`, which might be a breaking change.
Previously, `has_parameter_option("--no-plugins")` also matched `--no-plugins` after a `--` argument terminator; with `only_params=True`, those occurrences are now ignored. This risks breaking workflows that disable plugins while forwarding options after `--`. Consider preserving the old behavior for `--no-plugins` (e.g., a separate `has_parameter_option("--no-plugins")` call without `only_params`) while still using `only_params` to avoid loading plugins for `--version` / `-V`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
0aedbb0 to
427da14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10625.
Summary
--versionand-Vlike--no-pluginswhen deciding whether to load application plugins._load_plugins()instead of adding another fast path to_run().Tests
.venv/bin/python -m pytest tests/console/test_application.py::test_application_version_does_not_load_plugins -q.venv/bin/python -m pytest tests/console/test_application.py -q.venv/bin/python -m pytest tests/console/test_application.py tests/console/test_application_global_options.py -q.venv/bin/python -m poetry --version && .venv/bin/python -m poetry --version --no-plugins.venv/bin/ruff check src/poetry/console/application.py tests/console/test_application.py.venv/bin/ruff format --check src/poetry/console/application.py tests/console/test_application.py.venv/bin/mypy src/poetry/console/application.py tests/console/test_application.pygit diff --check