psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.24k stars 2.45k forks source link

precommit black doesn't read from `pyproject.toml` file. #4317

Open arshan-ritual opened 4 months ago

arshan-ritual commented 4 months ago

Describe the bug

My precommit file:

repos:
  - repo: https://github.com/psf/black
    rev: 24.4.0
    hooks:
      - id: black

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.0.289
    hooks:
      - id: ruff
        args: [--fix, --exit-non-zero-on-fix]

etc.

My pyproject.toml file:

[tool.black]
line-length = 89

[tool.isort]
profile = "black"
skip = [".gitignore", ".dockerignore"]

I'm running this. Black sets line length to 120 by default & doesn't read from my config.

pre-commit run --all-files
black....................................................................Passed
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1

src/chain/errors.py:56:90: E501 Line too long (103 > 89 characters)
src/chain/errors.py:57:90: E501 Line too long (103 > 89 characters)
src/chain/errors.py:58:90: E501 Line too long (107 > 89 characters)
src/chain/errors.py:59:90: E501 Line too long (112 > 89 characters)
src/chain/errors.py:61:90: E501 Line too long (96 > 89 characters)
src/chain/errors.py:63:90: E501 Line too long (99 > 89 characters)
src/chain/errors.py:64:90: E501 Line too long (115 > 89 characters)
Found 7 errors.

mypy.....................................................................Passed
isort (python)...........................................................Passed
Fix End of Files.........................................................Passed
Check for added large files..............................................Passed
Trim Trailing Whitespace.................................................Passed
JelleZijlstra commented 4 months ago

Black does not fix all issues with line length; see https://github.com/psf/black/issues?q=is%3Aopen+is%3Aissue+label%3A%22F%3A+linetoolong%22. Are you sure Black is applying a line length of 120, as opposed to just leaving some long lines alone?