Skip to content

[FR] Tool-specific toml config #1643

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

Open
webknjaz opened this issue Jun 16, 2023 · 8 comments · May be fixed by #1952
Open

[FR] Tool-specific toml config #1643

webknjaz opened this issue Jun 16, 2023 · 8 comments · May be fixed by #1952
Labels
enhancement New feature or request

Comments

@webknjaz
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I maintain enough projects to have a need to synchronize the configs occasionally. Synchronizing configs where sections tend to get shuffled is rather tricky on scale, which is one of the reasons for keeping configs in tool-specific files (the other reason, for me, is that it also makes it obvious where to look for a config right away). Some projects also make use of git skeletons that employ git merge to synchronize configs that are primarily maintained in an upstream "skeleton" repository to downstreams that may occasionally diverge over time — in such case, having configs separate also helps with reducing merge conflicts a lot.

.coveragerc already solves this problem, but since the ecosystem seems to be moving away from plain INI files (because of some shortcomings) towards using TOML, it seems natural for coverage.py to also have a TOML version of such a config.

Why not pyproject.toml? It's suitable for people who don't have to maintain similar configs for different tools across many projects, which is not my case, hence the feature request...

Describe the solution you'd like

I think there should be a .coveragerc.toml where people could put their configs that would take precedence over all other files (provided that either of tomli or tomllib is importable).
I expect that the structure (section names etc.) would be exactly the same as for pyproject.toml to allow for easy migration between the two (plus, it's easier to maintain as the parsing code could essentially be the same).

Describe alternatives you've considered

Keeping the config in .coveragerc.

Additional context

One example of using the Git skeleton approach is https://blog.jaraco.com/skeleton/.
Among other tools following this approach are Towncrier (supports towncrier.toml and pyproject.toml with the section name [tool.towncrier]) and pip-tools (supports .pip-tools.toml and pyproject.toml with the section name [tool.pip-tools]; release pending).

@webknjaz webknjaz added enhancement New feature or request needs triage labels Jun 16, 2023
@nedbat
Copy link
Owner

nedbat commented Jun 16, 2023

If you are going to have a separate file for each tool, then explain why .coveragerc isn't good? What's wrong with the .ini format for coverage's settings?

You can put configuration in a .coveragerc.toml file, but you need to specify it on the command line or in the COVERAGE_RCFILE environment variable.

@webknjaz
Copy link
Contributor Author

.coveragerc is good and I'll keep using it. I just wasn't sure if it'll get deprecated at some point. Really, my motivation here is just bring attention to such a possibility.

I know that I can rename the file and pass it explicitly but that's not something I'd want to do since different tools are called in different contexts outside of what I set up, sometimes. For example, if I set up flake8 to run through tox+pre-commit, I'd still want the end-user' editors that use some native integrations to pick up the same config automatically, zero friction, which is only possible if the file is picked up by default.

Though, again, I'm not going to be too upset if I'll need to stick with an ini file..

@nedbat
Copy link
Owner

nedbat commented Jun 17, 2023

We'll keep an eye on it and see if other tools start adopting a tool-specific.toml file pattern.

@nedbat nedbat closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2023
@trajano
Copy link

trajano commented Mar 26, 2025

  • ruff
  • pyright
  • poetry
  • black
  • isort

Are a few tools that adopted tool specific toml pattern

@webknjaz
Copy link
Contributor Author

Also, Hatch and PyLint.

@nedbat
Copy link
Owner

nedbat commented Mar 26, 2025

It seems there is growing support for this style of flexibility. If someone is interested in making a pull request, we can work on getting it merged.

@webknjaz
Copy link
Contributor Author

@nedbat does this deserve a good first issue label? Should be easy enough, right?

@OlenaYefymenko
Copy link

OlenaYefymenko commented Mar 26, 2025

@nedbat does this deserve a good first issue label? Should be easy enough, right?

@webknjaz,
UPD: I'm going to work on it and finish between next Monday and Wednesday.

@OlenaYefymenko OlenaYefymenko linked a pull request Apr 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants