From ca504d07cf5b715c9dcbc98ed14f0a454ffd9314 Mon Sep 17 00:00:00 2001 From: Muneeb Sheikh Date: Sun, 11 Oct 2026 13:46:40 -0400 Subject: [PATCH] Report the invalid aligned indentation value --- sqlparse/formatter.py | 2 +- tests/test_format.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py index 1fba2466..2da770ea 100644 --- a/sqlparse/formatter.py +++ b/sqlparse/formatter.py @@ -74,7 +74,7 @@ def validate_options(options): reindent_aligned = options.get('reindent_aligned', False) if reindent_aligned not in [True, False]: raise SQLParseError('Invalid value for reindent_aligned: ' - f'{reindent!r}') + f'{reindent_aligned!r}') elif reindent_aligned: options['strip_whitespace'] = True diff --git a/tests/test_format.py b/tests/test_format.py index 93495067..dc2109a7 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -5,6 +5,15 @@ class TestFormat: + @pytest.mark.parametrize('reindent', [True, False]) + @pytest.mark.parametrize('aligned', ['invalid', None, 2]) + def test_reindent_aligned_invalid_option_diagnostic(self, reindent, aligned): + with pytest.raises(SQLParseError) as exc: + sqlparse.format('select 1', reindent=reindent, + reindent_aligned=aligned) + assert str(exc.value) == ( + f'Invalid value for reindent_aligned: {aligned!r}') + def test_keywordcase(self): sql = 'select * from bar; -- select foo\n' res = sqlparse.format(sql, keyword_case='upper')