Skip to content

feat(minijinja): migrate litestar.contrib.minijinja to litestar.plugins.minijinja#4760

Merged
cofin merged 4 commits into
mainfrom
feat/minijinja-plugin
May 11, 2026
Merged

feat(minijinja): migrate litestar.contrib.minijinja to litestar.plugins.minijinja#4760
cofin merged 4 commits into
mainfrom
feat/minijinja-plugin

Conversation

@cofin

@cofin cofin commented May 10, 2026

Copy link
Copy Markdown
Member

Moves the MiniJinja template engine integration from litestar.contrib.minijinja to litestar.plugins.minijinja, and removes the contrib path on main. A follow-up PR onto v2 will add a deprecation shim covering both public and private symbols. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758).

litestar/plugins/flash.py lazily imports the private _transform_state from MiniJinja, so any deprecation shim has to forward private symbols. That diagnosis came from @xronocode's audit in #4754; this PR preserves it by migrating flash.py before deleting contrib, so every intermediate commit keeps the dependency graph valid.

Salvages the contrib tests into tests/unit/test_plugins/test_minijinja.py (98% coverage), migrates every internal call site, and adds docs/reference/plugins/minijinja.rst.

Closes #4718.


📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4760

@cofin
cofin requested review from a team as code owners May 10, 2026 00:20
@github-actions github-actions Bot added area/docs This PR involves changes to the documentation area/plugins This PR involves changes to the plugins size: medium type/feat pr/internal labels May 10, 2026
@codecov

codecov Bot commented May 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.41%. Comparing base (cc598c4) to head (491799a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4760      +/-   ##
==========================================
- Coverage   67.42%   67.41%   -0.01%     
==========================================
  Files         292      292              
  Lines       15019    15018       -1     
  Branches     1686     1686              
==========================================
- Hits        10127    10125       -2     
- Misses       4756     4757       +1     
  Partials      136      136              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cofin
cofin force-pushed the feat/minijinja-plugin branch from 2711260 to a68c278 Compare May 10, 2026 14:23
@cofin
cofin enabled auto-merge (squash) May 10, 2026 14:24
cofin and others added 4 commits May 11, 2026 10:25
Add the MiniJinja template engine integration as a flat module under
litestar.plugins (peer of htmx.py / flash.py / attrs.py). Drops the
contrib framing and the `from __future__ import annotations` import in
line with project conventions for new plugin modules.

Preserves the module-level `_transform_state` helper at the new path so
the lazy import inside `litestar.plugins.flash` can be migrated to the
plugin namespace without behavior change.

This is the main-side half of the 2-PR deprecation pattern; a
follow-up v2 PR will add the deprecation shim at
litestar.contrib.minijinja covering both public symbols and
`_transform_state`.

Co-authored-by: xronocode <myevdokimov@gmail.com>
…contrib path

- Migrate every internal call site (tests, doc examples, the lazy
  import inside `litestar.plugins.flash`) to
  `from litestar.plugins.minijinja import ...`. The flash.py change
  preserves the public/private split: it still imports both
  `MiniJinjaTemplateEngine` and the module-level `_transform_state`
  helper.
- Delete `litestar/contrib/minijinja.py`. The contrib path is gone on
  main; the v2 follow-up PR adds a deprecation shim at the contrib
  location covering both public symbols and `_transform_state`, so 2.x
  users (whose flash.py still imports from contrib) get a
  `DeprecationWarning` window with a real migration target on the
  version they are already running.
- Salvage the contrib functional tests into
  `tests/unit/test_plugins/test_minijinja.py` (99% line coverage on
  the new module) and delete `tests/unit/test_contrib/test_minijinja.py`.
- Add `docs/reference/plugins/minijinja.rst`; update the plugins
  reference toctree.

Co-authored-by: xronocode <myevdokimov@gmail.com>
@cofin
cofin force-pushed the feat/minijinja-plugin branch from a68c278 to 491799a Compare May 11, 2026 15:25
@cofin
cofin merged commit 893d30d into main May 11, 2026
23 checks passed
@cofin
cofin deleted the feat/minijinja-plugin branch May 11, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs This PR involves changes to the documentation area/plugins This PR involves changes to the plugins pr/internal size: medium type/feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(minijinja): deprecate litestar.contrib.minijinja and migrate to litestar.plugins.minijinja

2 participants