flake8 fixup

* fix trailing/ leading whitespaces
* fix None comparison to use is
+ add noqa ignore statements for the influx escape replacements
+ add noqa ignore statements around the bare excepts

TODO: This is only a temporary fix for most of the bare excepts, we need further specify those.
This commit is contained in:
nico 2020-06-29 18:59:16 +02:00
parent 5f0cb289c1
commit 044e0334d2
Signed by: mightyBroccoli
GPG Key ID: EA7C31AAB1BDC1A2
5 changed files with 10 additions and 10 deletions

2
api.py
View File

@ -53,6 +53,6 @@ class EjabberdApi:
return fn(self._login, data)
return fn(data)
except:
except: # noqa: E722
# this needs to be more specific
return {}

View File

@ -38,13 +38,13 @@ class EjabberdCleanup(EjabberdApiCalls):
lastdate = None
try:
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ")
except:
except: # noqa: E722
try:
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ")
except:
except: # noqa: E722
logging.error(f"{user}@{host}: not able to parse '{last_stamp}'")
return
if lastdate != None and lastdate - datetime.datetime.now() > datetime.timedelta(
if lastdate is not None and lastdate - datetime.datetime.now() > datetime.timedelta(
days=self.offline_since_days
):
self.delete_user(host, user, f"last seen @ {lastdate}")

View File

@ -21,8 +21,8 @@ class Influx:
@staticmethod
def _rmspace(key: str = None, value: (str, int) = None):
try:
key = key.replace(" ", "\ ")
value = value.replace(" ", "\ ")
key = key.replace(" ", "\ ") # noqa: W605
value = value.replace(" ", "\ ") # noqa: W605
except (TypeError, AttributeError):
pass

View File

@ -23,7 +23,7 @@ class DynamicMetricsHandler(BaseHTTPRequestHandler):
registry = registry.restricted_registry(params["name[]"])
try:
output = generate_latest(registry)
except:
except: # noqa: E722
self.send_error(500, "error generating metric output")
raise
self.send_response(200)