lint: various non-semantic fixes

This commit is contained in:
Iain Learmonth 2022-06-23 11:38:27 +01:00
parent cbd80cf7b3
commit 273dcb2a8a
5 changed files with 13 additions and 13 deletions

View file

@ -3,18 +3,18 @@ from __future__ import annotations
from typing import Any from typing import Any
def is_integer(n: Any) -> bool: def is_integer(contender: Any) -> bool:
""" """
Determine if a string (or other object type that can be converted automatically) represents an integer. Determine if a string (or other object type that can be converted automatically) represents an integer.
Thanks to https://note.nkmk.me/en/python-check-int-float/. Thanks to https://note.nkmk.me/en/python-check-int-float/.
:param n: object to test :param contender: object to test
:return: true if it's an integer :return: true if it's an integer
""" """
try: try:
float(n) float(contender)
except ValueError: except ValueError:
return False return False
else: else:
return float(n).is_integer() return float(contender).is_integer()

View file

@ -3,7 +3,7 @@ from datetime import datetime
from flask import render_template, url_for, flash, redirect, Response, Blueprint from flask import render_template, url_for, flash, redirect, Response, Blueprint
from flask.typing import ResponseReturnValue from flask.typing import ResponseReturnValue
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from sqlalchemy import exc import sqlalchemy
from wtforms import StringField, BooleanField, SubmitField from wtforms import StringField, BooleanField, SubmitField
from wtforms.validators import DataRequired from wtforms.validators import DataRequired
@ -52,8 +52,7 @@ def group_new() -> ResponseReturnValue:
db.session.commit() db.session.commit()
flash(f"Created new group {group.group_name}.", "success") flash(f"Created new group {group.group_name}.", "success")
return redirect(url_for("portal.group.group_edit", group_id=group.id)) return redirect(url_for("portal.group.group_edit", group_id=group.id))
except exc.SQLAlchemyError as e: except sqlalchemy.exc.SQLAlchemyError:
print(e)
flash("Failed to create new group.", "danger") flash("Failed to create new group.", "danger")
return redirect(url_for("portal.group.group_list")) return redirect(url_for("portal.group.group_list"))
return render_template("new.html.j2", section="group", form=form) return render_template("new.html.j2", section="group", form=form)
@ -77,7 +76,7 @@ def group_edit(group_id: int) -> ResponseReturnValue:
try: try:
db.session.commit() db.session.commit()
flash("Saved changes to group.", "success") flash("Saved changes to group.", "success")
except exc.SQLAlchemyError: except sqlalchemy.exc.SQLAlchemyError:
flash("An error occurred saving the changes to the group.", "danger") flash("An error occurred saving the changes to the group.", "danger")
return render_template("group.html.j2", return render_template("group.html.j2",
section="group", section="group",

View file

@ -16,10 +16,10 @@ bp = Blueprint("webhook", __name__)
@bp.app_template_filter("webhook_format_name") @bp.app_template_filter("webhook_format_name")
def webhook_format_name(s: str) -> str: def webhook_format_name(format: str) -> str:
if s == "telegram": if format == "telegram":
return "Telegram" return "Telegram"
if s == "matrix": if format == "matrix":
return "Matrix" return "Matrix"
return "Unknown" return "Unknown"

View file

@ -17,7 +17,7 @@ class BlockMirrorAutomation(BaseAutomation):
""" """
Constructor method. Constructor method.
""" """
self.patterns = list() self.patterns = []
super().__init__() super().__init__()
def automate(self, full: bool = False) -> Tuple[bool, str]: def automate(self, full: bool = False) -> Tuple[bool, str]:
@ -25,7 +25,7 @@ class BlockMirrorAutomation(BaseAutomation):
logging.debug("Fetch complete") logging.debug("Fetch complete")
self.parse() self.parse()
logging.debug("Parse complete") logging.debug("Parse complete")
rotated = list() rotated = []
proxy_urls = active_proxy_urls() proxy_urls = active_proxy_urls()
for pattern in self.patterns: for pattern in self.patterns:
blocked_urls = fnmatch.filter(proxy_urls, pattern) blocked_urls = fnmatch.filter(proxy_urls, pattern)

View file

@ -4,6 +4,7 @@ azure-identity
azure-mgmt-alertsmanagement azure-mgmt-alertsmanagement
bootstrap-flask bootstrap-flask
boto3~=1.21.15 boto3~=1.21.15
bs4
flask-migrate flask-migrate
flask-sqlalchemy flask-sqlalchemy
flask-wtf flask-wtf