lint: various non-semantic fixes
This commit is contained in:
parent
cbd80cf7b3
commit
273dcb2a8a
5 changed files with 13 additions and 13 deletions
|
@ -3,18 +3,18 @@ from __future__ import annotations
|
|||
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.
|
||||
|
||||
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
|
||||
"""
|
||||
try:
|
||||
float(n)
|
||||
float(contender)
|
||||
except ValueError:
|
||||
return False
|
||||
else:
|
||||
return float(n).is_integer()
|
||||
return float(contender).is_integer()
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import datetime
|
|||
from flask import render_template, url_for, flash, redirect, Response, Blueprint
|
||||
from flask.typing import ResponseReturnValue
|
||||
from flask_wtf import FlaskForm
|
||||
from sqlalchemy import exc
|
||||
import sqlalchemy
|
||||
from wtforms import StringField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
|
@ -52,8 +52,7 @@ def group_new() -> ResponseReturnValue:
|
|||
db.session.commit()
|
||||
flash(f"Created new group {group.group_name}.", "success")
|
||||
return redirect(url_for("portal.group.group_edit", group_id=group.id))
|
||||
except exc.SQLAlchemyError as e:
|
||||
print(e)
|
||||
except sqlalchemy.exc.SQLAlchemyError:
|
||||
flash("Failed to create new group.", "danger")
|
||||
return redirect(url_for("portal.group.group_list"))
|
||||
return render_template("new.html.j2", section="group", form=form)
|
||||
|
@ -77,7 +76,7 @@ def group_edit(group_id: int) -> ResponseReturnValue:
|
|||
try:
|
||||
db.session.commit()
|
||||
flash("Saved changes to group.", "success")
|
||||
except exc.SQLAlchemyError:
|
||||
except sqlalchemy.exc.SQLAlchemyError:
|
||||
flash("An error occurred saving the changes to the group.", "danger")
|
||||
return render_template("group.html.j2",
|
||||
section="group",
|
||||
|
|
|
@ -16,10 +16,10 @@ bp = Blueprint("webhook", __name__)
|
|||
|
||||
|
||||
@bp.app_template_filter("webhook_format_name")
|
||||
def webhook_format_name(s: str) -> str:
|
||||
if s == "telegram":
|
||||
def webhook_format_name(format: str) -> str:
|
||||
if format == "telegram":
|
||||
return "Telegram"
|
||||
if s == "matrix":
|
||||
if format == "matrix":
|
||||
return "Matrix"
|
||||
return "Unknown"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
"""
|
||||
Constructor method.
|
||||
"""
|
||||
self.patterns = list()
|
||||
self.patterns = []
|
||||
super().__init__()
|
||||
|
||||
def automate(self, full: bool = False) -> Tuple[bool, str]:
|
||||
|
@ -25,7 +25,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
logging.debug("Fetch complete")
|
||||
self.parse()
|
||||
logging.debug("Parse complete")
|
||||
rotated = list()
|
||||
rotated = []
|
||||
proxy_urls = active_proxy_urls()
|
||||
for pattern in self.patterns:
|
||||
blocked_urls = fnmatch.filter(proxy_urls, pattern)
|
||||
|
|
|
@ -4,6 +4,7 @@ azure-identity
|
|||
azure-mgmt-alertsmanagement
|
||||
bootstrap-flask
|
||||
boto3~=1.21.15
|
||||
bs4
|
||||
flask-migrate
|
||||
flask-sqlalchemy
|
||||
flask-wtf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue