From 4c77bdb8d92523935454f1c406c954913f923c01 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 2 Nov 2021 19:51:48 -0700 Subject: lint: resolve existing mypy type errors Adds annotations and re-workes dataflow to satisfy existing mypy issues, without adding any additional type annotations to, eg, function signatures. There will probably be many more type errors when annotations are all added. --- python/fatcat_web/graphics.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'python/fatcat_web/graphics.py') diff --git a/python/fatcat_web/graphics.py b/python/fatcat_web/graphics.py index c76408cd..82a0a577 100644 --- a/python/fatcat_web/graphics.py +++ b/python/fatcat_web/graphics.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Tuple +from typing import Any, Dict, List, Tuple import pygal from pygal.style import CleanStyle @@ -12,17 +12,17 @@ def ia_coverage_histogram(rows: List[Tuple]) -> pygal.Graph: """ raw_years = [int(r[0]) for r in rows] - years = dict() + years_dict = dict() if raw_years: for y in range(min(raw_years), max(raw_years) + 1): - years[int(y)] = dict(year=int(y), available=0, missing=0) + years_dict[int(y)] = dict(year=int(y), available=0, missing=0) for r in rows: if r[1]: - years[int(r[0])]["available"] = r[2] + years_dict[int(r[0])]["available"] = r[2] else: - years[int(r[0])]["missing"] = r[2] + years_dict[int(r[0])]["missing"] = r[2] - years = sorted(years.values(), key=lambda x: x["year"]) + years: List[Dict[str, Any]] = sorted(years_dict.values(), key=lambda x: x["year"]) CleanStyle.colors = ("green", "purple") label_count = len(years) @@ -39,9 +39,9 @@ def ia_coverage_histogram(rows: List[Tuple]) -> pygal.Graph: # chart.title = "Perpetual Access Coverage" chart.x_title = "Year" # chart.y_title = "Releases" - chart.x_labels = [str(y["year"]) for y in years] - chart.add("via Fatcat", [y["available"] for y in years]) - chart.add("Missing", [y["missing"] for y in years]) + chart.x_labels = [str(v["year"]) for v in years] + chart.add("via Fatcat", [v["available"] for v in years]) + chart.add("Missing", [v["missing"] for v in years]) return chart -- cgit v1.2.3