]> git.mxchange.org Git - fba.git/blobdiff - fba/federation/misskey.py
Fixed some issues found by pylint:
[fba.git] / fba / federation / misskey.py
index cb75a96e9ccc25e23d4c330f38f49f303abb687a..0a6ee127da10e5423e4d8b51d75716f7f0789c31 100644 (file)
@@ -24,10 +24,10 @@ from fba import network
 
 def fetch_peers(domain: str) -> list:
     # DEBUG: print(f"DEBUG: domain({len(domain)})={domain} - CALLED!")
-    if type(domain) != str:
+    if not isinstance(domain, str):
         raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
     elif domain == "":
-        raise ValueError(f"Parameter 'domain' is empty")
+        raise ValueError("Parameter 'domain' is empty")
 
     # DEBUG: print(f"DEBUG: domain='{domain}' is misskey, sending API POST request ...")
     peers = list()
@@ -81,7 +81,7 @@ def fetch_peers(domain: str) -> list:
             if not "host" in row:
                 print(f"WARNING: row()={len(row)} does not contain key 'host': {row},domain='{domain}'")
                 continue
-            elif type(row["host"]) != str:
+            elif not isinstance(row["host"], str):
                 print(f"WARNING: row[host][]={type(row['host'])} is not 'str'")
                 continue
             elif blacklist.is_blacklisted(row["host"]):
@@ -110,10 +110,10 @@ def fetch_peers(domain: str) -> list:
 
 def fetch_blocks(domain: str) -> dict:
     # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
-    if type(domain) != str:
+    if not isinstance(domain, str):
         raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
     elif domain == "":
-        raise ValueError(f"Parameter 'domain' is empty")
+        raise ValueError("Parameter 'domain' is empty")
 
     # DEBUG: print("DEBUG: Fetching misskey blocks from domain:", domain)
     blocklist = {
@@ -180,9 +180,9 @@ def fetch_blocks(domain: str) -> dict:
                 # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
                 break
 
-        except BaseException as e:
-            print("WARNING: Caught error, exiting loop:", domain, e)
-            instances.update_last_error(domain, e)
+        except BaseException as exception:
+            print("WARNING: Caught error, exiting loop:", domain, exception)
+            instances.update_last_error(domain, exception)
             offset = 0
             break
 
@@ -237,9 +237,9 @@ def fetch_blocks(domain: str) -> dict:
                 # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
                 break
 
-        except BaseException as e:
-            print("ERROR: Exception during POST:", domain, e)
-            instances.update_last_error(domain, e)
+        except BaseException as exception:
+            print("ERROR: Exception during POST:", domain, exception)
+            instances.update_last_error(domain, exception)
             offset = 0
             break