aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/web.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-06-29 21:46:51 -0700
committerBryan Newbold <bnewbold@archive.org>2020-06-29 21:46:51 -0700
commit4891e854a6e27075233a530e4782b1750c4e35dc (patch)
tree0fb5a3aa1ef776c3a50e571fd10e709c20ef286c /fatcat_scholar/web.py
parent35c1e59e1b4903ab7b4ac922199c0a55e3a20f5a (diff)
downloadfatcat-scholar-4891e854a6e27075233a530e4782b1750c4e35dc.tar.gz
fatcat-scholar-4891e854a6e27075233a530e4782b1750c4e35dc.zip
fix lint errors (and some small bugs)
Diffstat (limited to 'fatcat_scholar/web.py')
-rw-r--r--fatcat_scholar/web.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py
index 8b55f75..2d2678a 100644
--- a/fatcat_scholar/web.py
+++ b/fatcat_scholar/web.py
@@ -9,7 +9,7 @@ import babel.support
from fastapi import FastAPI, APIRouter, Request, Depends
from fastapi.staticfiles import StaticFiles
from dynaconf import settings
-from typing import Optional, List, Any
+from typing import Optional, Any
from fatcat_scholar.hacks import Jinja2Templates
from fatcat_scholar.search import do_fulltext_search, FulltextQuery, FulltextHits
@@ -71,20 +71,20 @@ web = APIRouter()
def locale_gettext(translations: Any) -> Any:
- def gt(s):
+ def gt(s): # noqa: ANN001,ANN201
return translations.ugettext(s)
return gt
def locale_ngettext(translations: Any) -> Any:
- def ngt(s, n):
+ def ngt(s, n): # noqa: ANN001,ANN201
return translations.ungettext(s)
return ngt
-def load_i18n_templates():
+def load_i18n_templates() -> Any:
"""
This is a hack to work around lack of per-request translation
(babel/gettext) locale switching in FastAPI and Starlette. Flask (and
@@ -111,7 +111,7 @@ def load_i18n_templates():
)
# remove a lot of whitespace in HTML output with these configs
templates.env.trim_blocks = True
- templates.env.istrip_blocks = True
+ templates.env.lstrip_blocks = True
# pass-through application settings to be available in templates
templates.env.globals["settings"] = settings
d[lang_opt] = templates
@@ -126,7 +126,7 @@ async def web_home(
request: Request,
lang: LangPrefix = Depends(LangPrefix),
content: ContentNegotiation = Depends(ContentNegotiation),
-):
+) -> Any:
if content.mimetype == "application/json":
return await home()
return i18n_templates[lang.code].TemplateResponse(
@@ -136,7 +136,7 @@ async def web_home(
@web.get("/about", include_in_schema=False)
-async def web_about(request: Request, lang: LangPrefix = Depends(LangPrefix)):
+async def web_about(request: Request, lang: LangPrefix = Depends(LangPrefix)) -> Any:
return i18n_templates[lang.code].TemplateResponse(
"about.html",
{"request": request, "locale": lang.code, "lang_prefix": lang.prefix},