I have below .pre-commit-config.yaml file.
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-byte-order-marker
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.287'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
I have demo.py python file where few lines are exceeding max-length 88 chars, in that case pre-commit only giving
E501 line too long (89 > 88 characters)
error instead of re-formatting that line.
Is there any way we can auto-fix such issues?
See the Ruff documentation:
IOW, no.
Since you're using Black, you can just disable the Ruff E501 rule; Black will keep your lines under its line-length (as well as it can).
Alternately, you can try the brand spanking new
ruff-format
hook for formatting your code and skip Black: