Skip to content

Declare jinja2 as a direct dependency#573

Open
jkukul wants to merge 1 commit into
long2ice:mainfrom
jkukul:main
Open

Declare jinja2 as a direct dependency#573
jkukul wants to merge 1 commit into
long2ice:mainfrom
jkukul:main

Conversation

@jkukul

@jkukul jkukul commented Jul 22, 2026

Copy link
Copy Markdown

fastapi_cache.coder imports starlette.templating unconditionally, which requires jinja2. Since Starlette 1.0 no longer bundles jinja2 (it's an optional extra), a minimal install crashes with 'ImportError: jinja2 must be installed to use Jinja2Templates'. The test suite missed this because the dev group pulls in jinja2 transitively via towncrier.

Fixes #568

Note: this slipped past CI because the test env installs the dev group (→ towncrierjinja2), so jinja2 is always incidentally present during tests. A CI job that pip installs the built wheel into a clean venv and runs python -c "import fastapi_cache" would catch this and any future undeclared runtime dep. I'm also happy to contribute it if you're interested.

fastapi_cache.coder imports starlette.templating unconditionally, which
requires jinja2. Since Starlette 1.0 no longer bundles jinja2 (it's an
optional extra), a minimal install crashes with 'ImportError: jinja2 must
be installed to use Jinja2Templates'. The test suite missed this because
the dev group pulls in jinja2 transitively via towncrier.

Fixes long2ice#568
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.

ImportError: jinja2 must be installed to use Jinja2Templates (Starlette 1.0 compatibility)

1 participant