Skip to content

Commit ee0c5be

Browse files
committed
Declare jinja2 as a direct dependency
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
1 parent b2143ef commit ee0c5be

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

changelog.d/568.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Declare `jinja2` as a direct dependency. `fastapi_cache.coder` imports `starlette.templating` unconditionally, which requires jinja2, but jinja2 is only an optional starlette extra (dropped from the base install in Starlette 1.0). This fixes `ImportError: jinja2 must be installed to use Jinja2Templates` on a minimal install.

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ uvicorn = "*"
2121
typing-extensions = { version = ">=4.1.0" }
2222
importlib-metadata = { version = "^6.6.0", python = "<3.8" }
2323
pendulum = "^3.0.0"
24+
# coder.py imports starlette.templating unconditionally, which requires jinja2.
25+
# jinja2 is only an optional starlette extra (dropped from the base install in
26+
# Starlette 1.0), so declare it explicitly here.
27+
jinja2 = "*"
2428
aiomcache = { version = "^0.8.2", optional = true }
2529
aiobotocore = {version = "^2.13.1", optional = true}
2630
redis = {version = "^5.0.8", extras = ["redis"]}

0 commit comments

Comments
 (0)