Skip to content

AI spam#2183

Closed
wayyoungboy wants to merge 1 commit into
pallets:mainfrom
wayyoungboy:fix-indent-empty-first-2176
Closed

AI spam#2183
wayyoungboy wants to merge 1 commit into
pallets:mainfrom
wayyoungboy:fix-indent-empty-first-2176

Conversation

@wayyoungboy

@wayyoungboy wayyoungboy commented Jun 6, 2026

Copy link
Copy Markdown

Fixes #2176.

Summary

  • Preserve an empty input when using indent(first=True, blank=False) instead of returning indentation spaces.
  • Keep existing behavior for non-empty first lines, blank=True, and multiline input.
  • Add a regression test for the empty-string case.

Verification

  • RED: PYTHONPATH=.deps:src /opt/miniconda3/bin/python3.13 -m pytest -q tests/test_filters.py::TestFilter::test_indent_empty_string_with_first failed before the fix with AssertionError: assert ' ' == ''.
  • GREEN: PYTHONPATH=.deps:src /opt/miniconda3/bin/python3.13 -m pytest -q tests/test_filters.py::TestFilter::test_indent_empty_string_with_first -> 1 passed.
  • PYTHONPATH=.deps:src /opt/miniconda3/bin/python3.13 -m pytest -q tests/test_filters.py -k indent -> 4 passed, 129 deselected.
  • PYTHONPATH=.deps:src /opt/miniconda3/bin/python3.13 -m pytest -q tests/test_filters.py -> 133 passed.
  • PYTHONPATH=.deps:src /opt/miniconda3/bin/python3.13 -m pytest -q -> 912 passed.
  • /opt/miniconda3/bin/python3.13 -m ruff check src/jinja2/filters.py tests/test_filters.py -> All checks passed.
  • git diff --check -> passed.

@davidism davidism closed this Jun 6, 2026
@davidism davidism changed the title Fix indent filter for empty string with first=True AI spam Jun 6, 2026
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.

indent filter ignores blank=False when first=True on first line

2 participants