aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-01-18 14:33:45 -0800
committerBryan Newbold <bnewbold@archive.org>2021-01-18 14:33:45 -0800
commitca11f5f79fe520b7b963d2a1263fe58523e211fd (patch)
tree58c16e8cff26c9dbbe0b8b43502b7bce7c980f25 /fatcat_scholar
parent3561dd54daadbcc4f076c699b87654b921d81c36 (diff)
downloadfatcat-scholar-ca11f5f79fe520b7b963d2a1263fe58523e211fd.tar.gz
fatcat-scholar-ca11f5f79fe520b7b963d2a1263fe58523e211fd.zip
lint: fix small bugs and type annotations
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/schema.py3
-rw-r--r--fatcat_scholar/search.py2
-rw-r--r--fatcat_scholar/web.py6
3 files changed, 6 insertions, 5 deletions
diff --git a/fatcat_scholar/schema.py b/fatcat_scholar/schema.py
index 2f0f04e..5ac3aab 100644
--- a/fatcat_scholar/schema.py
+++ b/fatcat_scholar/schema.py
@@ -142,7 +142,7 @@ class ScholarBiblio(BaseModel):
val = ", ".join(self.contrib_names)
if val:
val += ". "
- val += f' "self.title." '
+ val += f' "{self.title}." '
if self.container_name:
val += self.container_name
if self.volume and self.issue:
@@ -152,6 +152,7 @@ class ScholarBiblio(BaseModel):
if self.pages:
val += f": {self.pages}"
return val
+ return None
class ScholarFulltext(BaseModel):
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index e586bee..9bc5699 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -133,7 +133,7 @@ def transform_es_results(resp: Response) -> List[dict]:
# add ScholarDoc object as a helper (eg, to call python helpers)
try:
h["_obj"] = ScholarDoc.parse_obj(h)
- except:
+ except Exception:
pass
return results
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py
index 5d978d1..a54b4e4 100644
--- a/fatcat_scholar/web.py
+++ b/fatcat_scholar/web.py
@@ -5,7 +5,7 @@ So far there are few endpoints, so we just put them all here!
"""
import logging
-from typing import Optional, Any, List
+from typing import Optional, Any, List, Dict
from pydantic import BaseModel
import babel.support
@@ -271,7 +271,7 @@ app.mount("/static", StaticFiles(directory="fatcat_scholar/static"), name="stati
@app.get("/favicon.ico", include_in_schema=False)
-async def favicon():
+async def favicon() -> Any:
return FileResponse(
"fatcat_scholar/static/ia-favicon.ico", media_type="image/x-icon"
)
@@ -310,7 +310,7 @@ async def http_exception_handler(request: Request, exc: StarletteHTTPException)
status_code=exc.status_code,
)
else:
- resp = {"status_code": exc.status_code}
+ resp: Dict[str, Any] = {"status_code": exc.status_code}
if exc.detail:
resp["detail"] = exc.detail
return JSONResponse(status_code=exc.status_code, content=resp,)