Skip to content

Reject non-positive --line-length values - #5664

Merged
cobaltt7 merged 11 commits into
psf:mainfrom
Aathi-27:reject-non-positive-line-length
Nov 12, 2026
Merged

cobaltt7 merged 11 commits into
psf:mainfrom
Aathi-27:reject-non-positive-line-length

Conversation

@Aathi-27

@Aathi-27 Aathi-27 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5663.

Black currently accepts zero and negative line lengths from the command line and pyproject.toml without reporting a configuration error.

This changes the CLI option to click.IntRange(min=1), so those values are rejected with a usage error. The same validation covers pyproject.toml through Click's default_map. The programmatic black.Mode API is unchanged.

Adds an Unreleased changelog entry. Following review, the tests that depended on Click's error wording were removed, so this PR contains no new tests.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (3dfcfe1) to main (b4f1fca):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

Comment thread tests/test_black.py Resolved
Comment thread tests/test_black.py Resolved
@Aathi-27

Copy link
Copy Markdown
Contributor Author

Both requested test removals are done. Could a maintainer please approve the pending workflow runs and take another look when you have time? Thanks.

@cobaltt7

Copy link
Copy Markdown
Collaborator

Thanks!

@cobaltt7
cobaltt7 merged commit 0b2b5e5 into psf:main Nov 12, 2026
53 checks passed
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.

Reject non-positive --line-length values instead of silently accepting them

3 participants