You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reject non-positive --line-length values instead of silently accepting them #5663
Black accepts --line-length 0 or --line-length -1 without an error. A negative line-length in pyproject.toml is accepted too. It then formats valid code into extremely narrow output and exits successfully.
For example:
total = price * quantity * (1 + tax_rate)
Run:
black --line-length -1 example.py
The result is still valid Python, so this isn't source corruption. But the docs don't describe a meaning for non-positive line lengths. Would it make sense to reject them with a usage error?
I have a patch using click.IntRange(min=1) for the CLI option, which also validates pyproject.toml values, plus regression tests. The programmatic black.Mode API stays unchanged. This follows the input-validation approach in #5211.
Activity