Skip to content

feat: add black formatter for Python files#19016

Open
thiagohcaserta wants to merge 2 commits intoanomalyco:devfrom
thiagohcaserta:feat/add-black-formatter
Open

feat: add black formatter for Python files#19016
thiagohcaserta wants to merge 2 commits intoanomalyco:devfrom
thiagohcaserta:feat/add-black-formatter

Conversation

@thiagohcaserta
Copy link

Issue for this PR

Closes #19015

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds black as a built-in formatter for Python (.py, .pyi) files. Black is the most widely adopted Python formatter and many projects still depend on it.

To avoid conflicts with ruff (which is already supported), black defers to ruff — it only activates when:

  1. ruff is not enabled for the project
  2. black binary is found in PATH
  3. The project references black in its dependency files (requirements.txt, pyproject.toml, or Pipfile)

Runs black --quiet $FILE. Positioned right after the ruff formatter entry for semantic grouping.

How did you verify your code works?

Verified black --quiet <file> formats Python files in place. Tested the deference logic: when a project has ruff configured, black.enabled() returns false. When only black is in the project deps, it activates correctly. The pattern follows the same approach used by ruff and uv formatters.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add black formatter support for Python files

1 participant