Request: supporting sub-configs (aka per-directory config)
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
+1 to this request -- I am running into the same issue with sphinx docs and want a different line length for that code.
+1 for this. We have also usecases where we have different types of modules and scripts and for some of them it makes sense to have a different config. For example, formatting for a utility library, compared to a pyspark code can be different and one might need to customize the formatting for different modules in the code
+1. I just ran into the exact same use-case that for examples which are included in Sphinx documentation, a shorter line-length would be good.