Fix (most) mypy / flake8 errors

This commit is contained in:
Geoffrey Frogeye 2021-08-14 23:35:51 +02:00
parent 3dcccad39a
commit f165e5a094
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
4 changed files with 10 additions and 4 deletions

View file

@ -63,7 +63,7 @@ def collect_subdomains(url: str) -> typing.Iterable[str]:
for request in DRIVER.requests:
if request.response:
yield subdomain_from_url(request.path)
except:
except Exception:
log.exception("Error")
DRIVER.quit()
DRIVER = None

View file

@ -37,7 +37,7 @@ class Writer(multiprocessing.Process):
if recs_queue: # MP
super(Writer, self).__init__()
self.recs_queue = recs_queue
self.log = logging.getLogger(f"wr")
self.log = logging.getLogger("wr")
self.autosave_interval = autosave_interval
self.ip4_cache = ip4_cache
if not recs_queue: # No MP
@ -45,7 +45,7 @@ class Writer(multiprocessing.Process):
def open_db(self) -> None:
self.db = database.Database()
self.db.log = logging.getLogger(f"wr")
self.db.log = logging.getLogger("wr")
self.db.fill_ip4cache(max_size=self.ip4_cache)
def exec_record(self, record: Record) -> None:
@ -74,6 +74,7 @@ class Writer(multiprocessing.Process):
block: typing.List[Record]
for block in iter(self.recs_queue.get, None):
assert block
record: Record
for record in block:
self.exec_record(record)

View file

@ -4,6 +4,7 @@ import database
import argparse
import sys
import time
import typing
FUNCTION_MAP = {
"zone": database.Database.set_zone,

View file

@ -57,7 +57,11 @@ if __name__ == "__main__":
perc_all = (100 * pass_all / count_all) if count_all else 100
perc_den = (100 * pass_den / count_den) if count_den else 100
log.info(
"%s: Entries %d/%d (%.2f%%) | Allow %d/%d (%.2f%%) | Deny %d/%d (%.2f%%)",
(
"%s: Entries %d/%d (%.2f%%)"
" | Allow %d/%d (%.2f%%)"
"| Deny %d/%d (%.2f%%)"
),
filename,
pass_ent,
count_ent,