Request: supporting sub-configs (aka per-directory config)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 41.8k
- Forks
- 2.9k
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
I like black's default of 88-char line length, except for docs/ renderings, where code blocks may be rendered via Sphinx with 79 char width. This leads to unnecessary scrolling left/right to see the last 9 chars.
It would be useful to enable black to have sub-configurations. This was requested in https://github.com/psf/black/issues/1370, and was postponed into the future.
Describe the solution you'd like
Enabling subdirectories to have their own pyproject.toml, and black will accept overrides from that sub-pyproject.toml.
Describe alternatives you've considered
ruff is a project that adopted sub-configs through use of the extend keyword. It has been great, I have:
- One repo-wide config
- Two sub-configs:
docs/andtests/
This can be an example successful implementation of sub-configs.
Additional context
One counter argument is simplying invoking black once/config:
- Once for the repo root
- Once for the subdirectory with its special config
I think this complicates things (e.g. multiple make commands or multiple pre-commit hooks), though it is a valid workaround
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Black's existing repo-wide pyproject.toml discovery and the prior discussion in issue #1370. Use the mentioned docs/ and tests/ subdirectories, along with Ruff's extend-based configuration as a comparison point. Done means subdirectories can provide pyproject.toml overrides while the root configuration continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100