From 1e7b4847b4da24106572e690548b8716baa80a1e Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 8 Jan 2024 18:21:57 +0100 Subject: [PATCH] update FastAPI version lower limit to `>0.107.0` and adapt for new starlette version --- CHANGES.md | 4 ++++ pyproject.toml | 2 +- tipg/factory.py | 9 +++++---- tipg/main.py | 6 ++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b4ec0255..bffc3b96 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2` +## [unreleased] + +- update FastAPI version lower limit to `>0.107.0` and adapt for new starlette version + ## [0.5.7] - 2024-01-08 - add `tags` to all routes diff --git a/pyproject.toml b/pyproject.toml index f7b024f6..d67a799b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "orjson", "asyncpg>=0.23.0", "buildpg>=0.3", - "fastapi>=0.100.0,<0.107.0", + "fastapi>=0.107.0", "jinja2>=2.11.2,<4.0.0", "morecantile>=5.0,<6.0", "pydantic>=2.4,<3.0", diff --git a/tipg/factory.py b/tipg/factory.py index 9cefbfa0..b1debf54 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -51,10 +51,11 @@ mvt_settings = MVTSettings() features_settings = FeaturesSettings() -DEFAULT_TEMPLATES = Jinja2Templates( - directory="", - loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]), -) # type:ignore + +jinja2_env = jinja2.Environment( + loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) +) +DEFAULT_TEMPLATES = Jinja2Templates(env=jinja2_env) COMMON_CONFORMS = [ diff --git a/tipg/main.py b/tipg/main.py index 86fa45e0..568bcaec 100644 --- a/tipg/main.py +++ b/tipg/main.py @@ -79,10 +79,8 @@ async def lifespan(app: FastAPI): # default template directory templates_location.append(jinja2.PackageLoader(__package__, "templates")) -templates = Jinja2Templates( - directory="", # we need to set a dummy directory variable, see https://github.com/encode/starlette/issues/1214 - loader=jinja2.ChoiceLoader(templates_location), -) # type: ignore +jinja2_env = jinja2.Environment(loader=jinja2.ChoiceLoader(templates_location)) +templates = Jinja2Templates(env=jinja2_env) ogc_api = Endpoints( title=settings.name,