Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 21 Apr 2025 02:21:03 +0000 (04:21 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 21 Apr 2025 02:21:03 +0000 (04:21 +0200)
- fixed some tpzos (TypError -> TypeError, row[block] -> block[reason], ...)
- RuntimeException is RuntimeError (confusing as errors are hard for my understanding)
- used f-string instead (pylint is now a bit happier)
- still it is confusing with import errors?!

fba/commands.py
fba/helpers/software.py
fba/http/network.py
fba/models/blocks.py
fba/networks/mastodon.py

index bdfb163dec87b94a76a4c173763e4a77b865aeef..af28be68b23108a58068f93f1af0b01ddfc383e6 100644 (file)
 import inspect
 import json
 import logging
-import numpy
+
+import argparse
 import time
 import urllib
+import numpy
 
-import argparse
 import atoma
 import bs4
 import markdown
@@ -2090,7 +2091,7 @@ def check_obfuscations(args: argparse.Namespace) -> int:
         delete_sql = ", ".join([f"\'{pattern}\'" for pattern in deleted])
 
         logger.debug("delete_sql='%s'", delete_sql)
-        database.cursor.execute("DELETE FROM obfuscation WHERE pattern IN (%s)" % delete_sql)
+        database.cursor.execute(f"DELETE FROM obfuscation WHERE pattern IN ({delete_sql})")
 
         logger.debug("Invoking commit() ...")
         database.connection.commit()
index 33c03053759610acd9f2b26641d744ce8dc39cbb..2aadba9e3ad8162c44d7780e00ab86ab26888714 100644 (file)
@@ -298,7 +298,7 @@ def is_relay(software: str) -> bool:
     logger.debug("software='%s'- CALLED!", software)
 
     if not isinstance(software, str):
-        raise TypError(f"software[]='{type(software)}' is not type 'str'")
+        raise TypeError(f"software[]='{type(software)}' is not type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
 
index 006234f0ffc9c928bff0e45f23536e69d67b587a..fb7a7a9b38baef25b02785bc898231cfef246f6a 100644 (file)
@@ -445,7 +445,7 @@ def fetch_csv_rows (url: str) -> list:
     logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
     if not response.ok or response.status_code > 200 or len(response.content) == 0:
         logger.warning("Failed fetching url='%s': response.ok='%s',response.status_code=%d,response.content()=%d - EXIT!", url, response.ok, response.status_code, len(response.text))
-        raise RuntimeException(f"response.ok='{response.ok}',response.status_code={response.status_code},response.content()={len(response.content)} is unexpected")
+        raise RuntimeError(f"response.ok='{response.ok}',response.status_code={response.status_code},response.content()={len(response.content)} is unexpected")
 
     lines = response.content.decode("utf-8").splitlines()
     logger.debug("Reading %d lines, dialect=unix ...", len(lines))
@@ -455,7 +455,7 @@ def fetch_csv_rows (url: str) -> list:
 
     if reader is None:
         logger.warning("Failed parsing response.content()=%d as CSV content", len(response.content))
-        raise RuntimeException(f"reader is None after parsing {len(lines)} CSV lines")
+        raise RuntimeError(f"reader is None after parsing {len(lines)} CSV lines")
 
     # Init rows from CSV reader
     rows = list(reader)
index 38f4950e7514a67cfb8fc3bf31c549d94ffc93f4..b77c6680209c0d213d030ee4bffb91bdc6398fd7 100644 (file)
@@ -67,7 +67,7 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str) ->
     domain_helper.raise_on(blocked)
 
     if not isinstance(reason, str) and reason is not None:
-        raise TypError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+        raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
     elif not isinstance(block_level, str):
         raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
     elif block_level == "":
index 0e132fb7649e7ba60c876aaee0aa6db4351b4bbd..c4654c8c98a1cbb813e05157e4baf52d24e5a1ba 100644 (file)
@@ -202,7 +202,7 @@ def fetch_blocks(domain: str) -> list:
                 logger.warning("block[domain]='%s' has invalid block[digest]='%s' - SKIPPED!", block["domain"], block["digest"])
                 continue
 
-            logger.debug("block[reason]='%s' - BEFORE!", row["block"])
+            logger.debug("block[reason]='%s' - BEFORE!", block["reason"])
             reason = tidyup.reason(block["reason"]) if "reason" in block and block["reason"] not in [None, ""] else None
 
             logger.debug("Appending domain='%s',block[domain]='%s',reason='%s',block_level='%s' ...", domain, block["domain"], reason, block_level)