python: fix flake8 warnings and format with black
Most of the flake8 warnings in this repository were fairly trivial,
so fixed them. The "openbmctool" is 7000+ lines of pretty heavily
warned code, so just disabling that one. Format everything with
black.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Icb3f6ee9bf03dece58785f7af00617c87a84aa65
diff --git a/tof-voters/libvoters/entry_point.py b/tof-voters/libvoters/entry_point.py
index 1dd50c3..a6cc1ea 100644
--- a/tof-voters/libvoters/entry_point.py
+++ b/tof-voters/libvoters/entry_point.py
@@ -2,7 +2,7 @@
import argparse
from importlib import import_module
-from typing import List
+
def main() -> int:
parser = argparse.ArgumentParser(description="Obtain TOF voter metrics")
@@ -22,7 +22,7 @@
import_module("libvoters.subcmd.dump-gerrit"),
import_module("libvoters.subcmd.report"),
]
- commands = [x.subcmd(subparser) for x in commands] # type: ignore
+ commands = [x.subcmd(subparser) for x in commands] # type: ignore
args = parser.parse_args()
diff --git a/tof-voters/libvoters/subcmd/analyze-commits.py b/tof-voters/libvoters/subcmd/analyze-commits.py
index 4717991..4939a0b 100644
--- a/tof-voters/libvoters/subcmd/analyze-commits.py
+++ b/tof-voters/libvoters/subcmd/analyze-commits.py
@@ -2,13 +2,14 @@
import argparse
import json
-import libvoters.acceptable as acceptable
import os
import re
from collections import defaultdict
-from libvoters.time import timestamp, TimeOfDay
from typing import Any, Dict
+import libvoters.acceptable as acceptable
+from libvoters.time import TimeOfDay, timestamp
+
class subcmd:
def __init__(self, parser: argparse._SubParsersAction) -> None:
@@ -42,7 +43,7 @@
if not os.path.isfile(path):
continue
- if not re.match("[0-9]*\.json", f):
+ if not re.match(r"[0-9]*\.json", f):
continue
with open(path, "r") as file:
diff --git a/tof-voters/libvoters/subcmd/analyze-reviews.py b/tof-voters/libvoters/subcmd/analyze-reviews.py
index b3734b9..b3323fa 100644
--- a/tof-voters/libvoters/subcmd/analyze-reviews.py
+++ b/tof-voters/libvoters/subcmd/analyze-reviews.py
@@ -4,11 +4,12 @@
import json
import os
import re
-import libvoters.acceptable as acceptable
from collections import defaultdict
-from libvoters.time import timestamp, TimeOfDay
from typing import Dict
+import libvoters.acceptable as acceptable
+from libvoters.time import TimeOfDay, timestamp
+
class subcmd:
def __init__(self, parser: argparse._SubParsersAction) -> None:
@@ -42,7 +43,7 @@
if not os.path.isfile(path):
continue
- if not re.match("[0-9]*\.json", f):
+ if not re.match(r"[0-9]*\.json", f):
continue
with open(path, "r") as file:
diff --git a/tof-voters/libvoters/subcmd/report.py b/tof-voters/libvoters/subcmd/report.py
index 13726d9..87aa713 100644
--- a/tof-voters/libvoters/subcmd/report.py
+++ b/tof-voters/libvoters/subcmd/report.py
@@ -7,13 +7,10 @@
class subcmd:
def __init__(self, parser: argparse._SubParsersAction) -> None:
- p = parser.add_parser(
- "report", help="Create final report"
- )
+ p = parser.add_parser("report", help="Create final report")
p.set_defaults(cmd=self)
-
def run(self, args: argparse.Namespace) -> int:
commits_fp = os.path.join(args.dir, "commits.json")
reviews_fp = os.path.join(args.dir, "reviews.json")
@@ -43,10 +40,14 @@
qualified = points >= 15
- results[user] = { "qualified": qualified, "points": points,
- "commits": user_commits, "reviews": user_reviews }
+ results[user] = {
+ "qualified": qualified,
+ "points": points,
+ "commits": user_commits,
+ "reviews": user_reviews,
+ }
with open(os.path.join(args.dir, "report.json"), "w") as outfile:
- outfile.write(json.dumps(results, indent = 4))
+ outfile.write(json.dumps(results, indent=4))
return 0