Skip to content

Request: supporting sub-configs (aka per-directory config) #3952

@jamesbraza

Description

@jamesbraza

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 #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/ and tests/

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions