python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.07k stars 2.26k forks source link

Use `poetry.toml` everywhere instead of `config.toml` in some places and `poetry.toml` in other #8847

Open valentincalomme opened 8 months ago

valentincalomme commented 8 months ago

I encountered some confusion while reading the documentation for Poetry's configuration (https://python-poetry.org/docs/configuration/). The documentation states:

Poetry can be configured via the config command (see more about its usage here) or directly in the config.toml file that will be automatically created when you first run that command.

Initially, I interpreted this to mean that a config.toml file was required in my project repository for local configuration. However, I noticed that running poetry config with the --local flag actually generates a poetry.toml file, not a config.toml.

While this discrepancy might not significantly impact the usage of global configuration, which is often accessed programmatically rather than manually, it can lead to confusion due to the inconsistency in file naming conventions for different configuration scopes.

I propose standardizing the configuration file name to poetry.toml for local and global configurations. My reasons for this preference are:

This standardization could enhance clarity and consistency in Poetry's configuration process.

dimbleby commented 8 months ago

potential conflicts with other tools that might also use a generic config.toml.

these conflicts are non-existent since the poetry configuration file lives in a poetry-specific directory

obviously would need a lengthy period of overlap where both files were valid, for backwards compatibility.

I doubt there's enough upside to making the change to justify the upheaval and effort: but if you're willing to make that effort then submit a merge request!

valentincalomme commented 8 months ago

That's fair. I think that the documentation could be updated to be clearer. I will give it a go and make a pull request if I find a way.

My main "issue" is that I think it should be clearer that you can create a poetry.toml file. I would actually be in favor of a poetry config --global flag. So that by default, configuring poetry works locally with the poetry.toml file. But that's more a personal preference.

amoralesc commented 1 month ago

I think this is a good place to ask since I found no other discussion on the topic.

Documentation suggests that one can store local configuration about Poetry in a project-level poetry.toml file. Will more standards for this file ever be supported?

For example, tools like Prettier support a plethora of standards for its config file, like TOML, YAML, JSON, JavaScript. Python tools like Ruff support the same TOML standard, but the config can be located at pyproject.toml, ruff.toml or .ruff.toml.

While I see no need for the added complexity that supporting different file formats for the configuration of the tool brings, I could see value in supporting both a local poetry.toml and .poetry.toml (and perhaps a [poetry] section in pyproject.toml if it made sense). The usage of dotfiles is mainly to remove visual clutter when scanning the file tree of a project. Most code editors, as well as the ls command on linux, can easily hide these dotfiles that are not immediately needed (but rather modified once or twice, when the project is first created).

Having a local poetry.toml is great because I can modify the behavior of Poetry on a project-per-project basis. But I don't necessarily want it next to my main.py or README.md at the project's root. Having it neatly hidden in the dotfiles section (.poetry.toml), next to things like my .gitignore or .ruff.toml would be cool.