From f9b69d0b4343403ecf9318dc6d66725f6144edad Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 Feb 2022 20:59:03 -0800 Subject: hack around mypy complaints --- python/fatcat_web/routes.py | 6 +++--- python/fatcat_web/search.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index f229a572..1f6602d4 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -364,7 +364,7 @@ def container_view_browse(ident: str) -> AnyResponse: query_sort: Optional[List[str]] if request.args.get("year") and "volume" in request.args and "issue" in request.args: # year, volume, issue specified; browse-by-page - year = int(request.args.get("year")) + year = int(request.args["year"]) volume = request.args.get("volume", "") issue = request.args.get("issue", "") if volume: @@ -379,7 +379,7 @@ def container_view_browse(ident: str) -> AnyResponse: query_sort = ["first_page", "pages", "release_date"] elif request.args.get("year") and "volume" in request.args: # year, volume specified (no issue); browse-by-page - year = int(request.args.get("year")) + year = int(request.args["year"]) volume = request.args.get("volume", "") if volume: volume = f'volume:"{volume}"' @@ -389,7 +389,7 @@ def container_view_browse(ident: str) -> AnyResponse: query_sort = ["issue", "first_page", "pages", "release_date"] elif request.args.get("year"): # year specified, not anything else; browse-by-date - year = int(request.args.get("year")) + year = int(request.args["year"]) query_string = f"year:{year}" query_sort = ["release_date"] elif request.args.get("volume"): diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index b48302b0..913d6696 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -247,7 +247,7 @@ def get_elastic_container_random_releases(ident: str, limit: int = 5) -> List[Di return results -def _sort_vol_key(val: Optional[str]) -> Tuple[bool, bool, int, str]: +def _sort_vol_key(val: Optional[Any]) -> Tuple[bool, bool, int, str]: """ Helper for sorting volume and issue strings. Defined order is: @@ -255,7 +255,10 @@ def _sort_vol_key(val: Optional[str]) -> Tuple[bool, bool, int, str]: - any non-integers next, in non-integer order - any integers next, in integer sorted order (ascending) - Note that the actual sort used/displayed is reversed + Note that the actual sort used/displayed is reversed. + + TODO: 'val' should actually be Optional[str], but getting a mypy error I + don't know how to hack around quickly right now. """ if val is None: return (False, False, 0, "") -- cgit v1.2.3