Skip to content

fix: add type annotation for FILTERS and TESTS dictionaries#2139

Closed
nightcityblade wants to merge 1 commit intopallets:mainfrom
nightcityblade:fix/issue-2120
Closed

fix: add type annotation for FILTERS and TESTS dictionaries#2139
nightcityblade wants to merge 1 commit intopallets:mainfrom
nightcityblade:fix/issue-2120

Conversation

@nightcityblade
Copy link
Copy Markdown

Closes #2120

Summary

Add explicit dict[str, t.Callable[..., t.Any]] type annotations to the module-level FILTERS dict in filters.py and TESTS dict in tests.py.

This allows type checkers (Pylance/Pyright/mypy) to properly infer the type of Environment.filters and Environment.tests, which are copied from these module-level dicts.

Changes

  • src/jinja2/filters.py: Add type annotation to FILTERS
  • src/jinja2/tests.py: Add type annotation to TESTS

Tests

  • mypy: Success, no issues found
  • ruff: All checks passed
  • pytest: 911 passed in 1.32s

Add explicit type annotations to the module-level `FILTERS` and
`TESTS` dictionaries so that type checkers like Pylance/Pyright
can properly infer the type of `Environment.filters` and
`Environment.tests`.

Closes pallets#2120
@davidism davidism closed this Feb 23, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing type annotation for FILTERS

2 participants