Skip to content

Parse CLI boolean values explicitly - #904

Open
xuu33030 wants to merge 1 commit into
andialbrecht:masterfrom
xuu33030:fix/cli-boolean-values-638
Open

xuu33030 wants to merge 1 commit into
andialbrecht:masterfrom
xuu33030:fix/cli-boolean-values-638

Conversation

@xuu33030

Copy link
Copy Markdown

Summary

sqlformat --comma_first False currently enables comma-first formatting: argparse calls bool('False'), which is true. The same problem affects --compact; even xxx is silently accepted as true.

Keep the existing value-taking syntax and false defaults, but parse true/false case-insensitively and 1/0 explicitly. Reject other values with an argparse error. The help text now lists the accepted values, and the changelog records the behavior change. No formatter API or formatting algorithm changes.

Closes #638.

Validation

  • Before the fix: 8 new false-value cases fail and 8 true-value controls pass.
  • Full suite on macOS with CPython 3.10.20, 3.11.15, 3.12.14, 3.13.5 and 3.14.6: 540 passed, 2 xfailed, 1 xpassed on each version. The xfail/xpass results are also present on the unmodified baseline (506 passed, 2 xfailed, 1 xpassed on 3.12).
  • Command: uv run --frozen --group dev --python <version> pytest tests/ -q.
  • Tests cover valid values, defaults, invalid values, and actual python -m sqlparse subprocess output for both options.
  • uv run --frozen --group dev ruff check sqlparse/ and git diff --check pass.
  • Windows, Linux and PyPy were not run locally.

Checklist

  • ran the tests (pytest)
  • all style issues addressed (ruff)
  • changes are covered by tests
  • changes are documented (CLI help and changelog)

AI disclosure: Hermes Agent assisted with investigation, implementation, tests and this description under the submitting account owner's authorization. No independent human review is claimed.

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.

Document options for sqlformat --comma_first

1 participant