poetry
poetry copied to clipboard
fix: respect local config file in `poetry python` commands
https://github.com/python-poetry/poetry/pull/10595 should be merged first, otherwise we are unable to set the relevant configs anyway.
Pull Request Check List
Resolves: #issue-number-here
- [ ] Added tests for changed code.
- [ ] Updated documentation for changed code.
Summary by Sourcery
Enhancements:
- Add PoetryPythonPathProvider.base_installation_dir to load and merge local poetry.toml into the config for determining python installation paths
Reviewer's Guide
This PR refactors the determination of Poetry’s python installation directory by introducing a new base_installation_dir method that merges settings from a local poetry.toml, and updates all provider implementations and console commands to use this method instead of directly calling Config.create().
Class diagram for updated PoetryPythonPathProvider and related usage
classDiagram
class PoetryPythonPathProvider {
+base_installation_dir() Path
+installation_dir(version: Version, implementation: str) Path
+_make_bin_paths(base: Path | None) list[Path]
}
class Config {
+create() Config
python_installation_dir Path
+merge(data)
}
class TOMLFile {
+read()
+exists()
}
class Factory {
+locate()
}
class PythonInstaller
class python_remove_py
class python_list_py
PoetryPythonPathProvider --|> PathProvider
PoetryPythonPathProvider ..> Config : uses
PoetryPythonPathProvider ..> TOMLFile : uses
PoetryPythonPathProvider ..> Factory : uses
PythonInstaller o-- PoetryPythonPathProvider : uses base_installation_dir
python_remove_py o-- PoetryPythonPathProvider : uses installation_dir
python_list_py o-- PoetryPythonPathProvider : uses base_installation_dir
Flow diagram for resolving python installation directory with local config
flowchart TD
A["Start: Need python installation directory"] --> B["Check for local poetry.toml config file"]
B -->|Exists| C["Merge local config into main config"]
B -->|Does not exist| D["Use main config only"]
C --> E["Return python_installation_dir from merged config"]
D --> E
E["Directory used for python installation"]
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Added base_installation_dir method that merges local poetry.toml into the global config |
|
src/poetry/utils/env/python/providers.py |
| Updated provider methods to use the new base_installation_dir |
|
src/poetry/utils/env/python/providers.py |
| Replaced direct Config.create().python_installation_dir calls in CLI commands |
|
src/poetry/console/commands/python/remove.pysrc/poetry/console/commands/python/list.py |
| Updated PythonInstaller to use the new provider for default installation directory |
|
src/poetry/utils/env/python/installer.py |
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto 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
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.