aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/forms.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-12 22:07:12 +0100
committerDennis Fink2026-11-12 22:07:12 +0100
commitc7993952c585b66acad5275e39dbf91cf662b975 (patch)
tree976b3746444b3bd0bbb269bef9197c8b6a2e1696 /webmentions_ssg/forms.py
parentb930b4425b91aa42abcec6c3443685065a5ca242 (diff)
downloadwebmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.tar.gz
webmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.zip
chore(core): enable stricter Ruff lint rules
Expand Ruff checks for bugbear, complexity, pathlib, return statements, simplifications, upgrades, and docstring style. Apply the resulting behavior-neutral cleanup across application and test code.
Diffstat (limited to 'webmentions_ssg/forms.py')
-rw-r--r--webmentions_ssg/forms.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/webmentions_ssg/forms.py b/webmentions_ssg/forms.py
index a721dc6..d557907 100644
--- a/webmentions_ssg/forms.py
+++ b/webmentions_ssg/forms.py
@@ -73,16 +73,14 @@ class HTTPXURL:
class NotEqualTo:
- """
- Validate that a field does not equal another field.
+ """Validate that a field does not equal another field.
:param fieldname: Name of the field to compare against.
:param message: Optional validation error message.
"""
def __init__(self, fieldname: str, message: str | None = None) -> None:
- """
- Initialize the validator.
+ """Initialize the validator.
:param fieldname: Name of the field to compare against.
:param message: Optional validation error message.
@@ -91,8 +89,7 @@ class NotEqualTo:
self.message = message
def __call__(self, form: BaseForm, field: Field) -> None:
- """
- Validate that two fields do not contain equal values.
+ """Validate that two fields do not contain equal values.
:param form: Form containing the fields to compare.
:param field: Field being validated.
@@ -110,8 +107,7 @@ class NotEqualTo:
return
d = {
- "other_label": hasattr(other, "label")
- and other.label.text
+ "other_label": (hasattr(other, "label") and other.label.text)
or self.fieldname,
"other_name": self.fieldname,
}
@@ -122,23 +118,20 @@ class NotEqualTo:
class AllowedHostname:
- """
- Validate that a URL uses an allowed hostname.
+ """Validate that a URL uses an allowed hostname.
:param message: Optional validation error message.
"""
def __init__(self, message: str | None = None) -> None:
- """
- Initialize the validator.
+ """Initialize the validator.
:param message: Optional validation error message.
"""
self.message = message
def __call__(self, form: BaseForm, field: Field) -> None:
- """
- Validate that a URL uses an allowed hostname.
+ """Validate that a URL uses an allowed hostname.
:param form: Form containing the field.
:param field: Field containing the URL to validate.
@@ -175,9 +168,7 @@ class PublicIPLiteral:
class LoginForm(FlaskForm):
- """
- Form for authenticating a user.
- """
+ """Form for authenticating a user."""
username = StringField("Username", validators=[InputRequired()])
password = PasswordField("Password", validators=[InputRequired()])
@@ -185,8 +176,7 @@ class LoginForm(FlaskForm):
class EndpointForm(FlaskForm):
- """
- Form for receiving a Webmention.
+ """Form for receiving a Webmention.
The source must be a public HTTP or HTTPS URL distinct from the target.
The target must be an HTTP or HTTPS URL using an allowed hostname.
@@ -226,8 +216,6 @@ class EndpointForm(FlaskForm):
class AdminActionForm(FlaskForm):
- """
- Form for confirming an administrative action.
- """
+ """Form for confirming an administrative action."""
submit = SubmitField("Confirm")