Skip to content

Commit 9a77782

Browse files
committed
Run ruff on code
1 parent 635fc42 commit 9a77782

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

backend/models/form.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ def validate_features(cls, value: list[str]) -> list[str]:
7575
raise ValueError(msg)
7676

7777
if FormFeatures.REQUIRES_LOGIN.value not in value:
78-
require_login_feature = [FormFeatures.COLLECT_EMAIL, FormFeatures.ASSIGN_ROLE, FormFeatures.UNIQUE_RESPONDER]
78+
require_login_feature = [
79+
FormFeatures.COLLECT_EMAIL,
80+
FormFeatures.ASSIGN_ROLE,
81+
FormFeatures.UNIQUE_RESPONDER,
82+
]
7983

8084
for feature in require_login_feature:
8185
if feature.value in value:

backend/routes/auth/authorize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def process_token(
5757
# Legacy key, we should use exp and use JWT expiry as below it.
5858
"expiry": token_expiry.isoformat(),
5959
# Correct JWT expiry key:
60-
"exp": token_expiry
60+
"exp": token_expiry,
6161
}
6262

6363
token = jwt.encode(data, SECRET_KEY, algorithm="HS256")

backend/routes/forms/form.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ class SingleForm(Route):
5656
name = "form"
5757
path = "/{form_id:str}"
5858

59-
@api.validate(resp=Response(HTTP_200=FormWithAncillaryData, HTTP_404=ErrorMessage), tags=["forms"])
59+
@api.validate(
60+
resp=Response(HTTP_200=FormWithAncillaryData, HTTP_404=ErrorMessage), tags=["forms"]
61+
)
6062
async def get(self, request: Request) -> JSONResponse:
6163
"""Returns single form information by ID."""
6264
form_id = request.path_params["form_id"].lower()
@@ -92,29 +94,30 @@ async def get(self, request: Request) -> JSONResponse:
9294
form.submission_precheck.problems.append(
9395
SubmissionProblem(
9496
severity=SubmissionPrecheckSeverity.DANGER,
95-
message="This form is not open for submissions at the moment."
97+
message="This form is not open for submissions at the moment.",
9698
)
9799
)
98100
form.submission_precheck.can_submit = False
99101
elif constants.FormFeatures.UNIQUE_RESPONDER.value in form.features:
100102
user_id = request.user.payload["id"] if request.user.is_authenticated else None
101103
if user_id:
102-
existing_response = await request.state.db.responses.find_one(
103-
{"form_id": form_id, "user.id": user_id}
104-
)
104+
existing_response = await request.state.db.responses.find_one({
105+
"form_id": form_id,
106+
"user.id": user_id,
107+
})
105108
if existing_response:
106109
form.submission_precheck.problems.append(
107110
SubmissionProblem(
108111
severity=SubmissionPrecheckSeverity.DANGER,
109-
message="You have already submitted a response to this form."
112+
message="You have already submitted a response to this form.",
110113
)
111114
)
112115
form.submission_precheck.can_submit = False
113116
else:
114117
form.submission_precheck.problems.append(
115118
SubmissionProblem(
116119
severity=SubmissionPrecheckSeverity.SECONDARY,
117-
message="You must login at the bottom of the page before submitting this form."
120+
message="You must login at the bottom of the page before submitting this form.",
118121
)
119122
)
120123

backend/routes/forms/submit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ async def submit(self, request: Request) -> JSONResponse:
182182
)
183183
if existing_response:
184184
return JSONResponse(
185-
{"error": "unique_responder", "message": "You have already submitted this form."},
185+
{
186+
"error": "unique_responder",
187+
"message": "You have already submitted this form.",
188+
},
186189
status_code=400,
187190
)
188191

0 commit comments

Comments
 (0)