aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/graphics.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-02 19:51:48 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-02 19:51:51 -0700
commit4c77bdb8d92523935454f1c406c954913f923c01 (patch)
tree2b2a1221cc78683afb9f18a87ccfd10ef0afbc64 /python/fatcat_web/graphics.py
parent3da07382d682a0c474ddc79f748a50ad2cc758cd (diff)
downloadfatcat-4c77bdb8d92523935454f1c406c954913f923c01.tar.gz
fatcat-4c77bdb8d92523935454f1c406c954913f923c01.zip
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.
Diffstat (limited to 'python/fatcat_web/graphics.py')
-rw-r--r--python/fatcat_web/graphics.py18
1 files changed, 9 insertions, 9 deletions
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