aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backend/constants.py8
-rw-r--r--backend/models/form.py2
-rw-r--r--backend/routes/forms/form.py2
-rw-r--r--backend/routes/forms/submit.py15
-rw-r--r--backend/routes/forms/unittesting.py3
-rw-r--r--tox.ini4
6 files changed, 22 insertions, 12 deletions
diff --git a/backend/constants.py b/backend/constants.py
index cccf437..59b56e0 100644
--- a/backend/constants.py
+++ b/backend/constants.py
@@ -1,9 +1,9 @@
from dotenv import load_dotenv
-load_dotenv()
+import os
+import binascii
+from enum import Enum
-import os # noqa
-import binascii # noqa
-from enum import Enum # noqa
+load_dotenv()
FRONTEND_URL = os.getenv("FRONTEND_URL", "https://forms.pythondiscord.com")
diff --git a/backend/models/form.py b/backend/models/form.py
index 8e59905..eac0b63 100644
--- a/backend/models/form.py
+++ b/backend/models/form.py
@@ -47,7 +47,7 @@ class Form(BaseModel):
if any(v not in allowed_values for v in value):
raise ValueError("Form features list contains one or more invalid values.")
- if FormFeatures.COLLECT_EMAIL in value and FormFeatures.REQUIRES_LOGIN not in value: # noqa
+ if FormFeatures.COLLECT_EMAIL in value and FormFeatures.REQUIRES_LOGIN not in value:
raise ValueError("COLLECT_EMAIL feature require REQUIRES_LOGIN feature.")
return value
diff --git a/backend/routes/forms/form.py b/backend/routes/forms/form.py
index b6b722e..e5f7ec6 100644
--- a/backend/routes/forms/form.py
+++ b/backend/routes/forms/form.py
@@ -26,7 +26,7 @@ class SingleForm(Route):
@api.validate(resp=Response(HTTP_200=Form, HTTP_404=ErrorMessage), tags=["forms"])
async def get(self, request: Request) -> JSONResponse:
"""Returns single form information by ID."""
- admin = request.user.payload["admin"] if request.user.is_authenticated else False # noqa
+ admin = request.user.payload["admin"] if request.user.is_authenticated else False
filters = {
"_id": request.path_params["form_id"]
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py
index 85a4226..c19fc2d 100644
--- a/backend/routes/forms/submit.py
+++ b/backend/routes/forms/submit.py
@@ -100,7 +100,10 @@ class SubmitForm(Route):
if request.user.is_authenticated:
response["user"] = request.user.payload
- if FormFeatures.COLLECT_EMAIL.value in form.features and "email" not in response["user"]: # noqa
+ if (
+ FormFeatures.COLLECT_EMAIL.value in form.features
+ and "email" not in response["user"]
+ ):
return JSONResponse({
"error": "email_required"
}, status_code=400)
@@ -134,11 +137,15 @@ class SubmitForm(Route):
was_successful = all(test.passed for test in unittest_results)
if not was_successful:
- status_code = 500 if any(test.return_code == 99 for test in unittest_results) else 200
+ status_code = 500 if any(
+ test.return_code == 99 for test in unittest_results
+ ) else 200
return JSONResponse({
"error": "failed_tests",
- "test_results": [test._asdict() for test in unittest_results if not test.passed]
+ "test_results": [
+ test._asdict() for test in unittest_results if not test.passed
+ ]
}, status_code=status_code)
await request.state.db.responses.insert_one(
@@ -186,7 +193,7 @@ class SubmitForm(Route):
embed = {
"title": "New Form Response",
"description": f"{mention} submitted a response to `{form.name}`.",
- "url": f"{FRONTEND_URL}/path_to_view_form/{response.id}", # noqa # TODO: Enter Form View URL
+ "url": f"{FRONTEND_URL}/path_to_view_form/{response.id}", # TODO: Enter Form View URL
"timestamp": response.timestamp,
"color": 7506394,
}
diff --git a/backend/routes/forms/unittesting.py b/backend/routes/forms/unittesting.py
index 3e1d280..fe8320f 100644
--- a/backend/routes/forms/unittesting.py
+++ b/backend/routes/forms/unittesting.py
@@ -51,7 +51,8 @@ async def execute_unittest(form_response: FormResponse, form: Form) -> list[Unit
unit_code = _make_unit_code(question.data["unittests"])
user_code = _make_user_code(form_response.response[question.id])
- code = TEST_TEMPLATE.replace("### USER CODE", user_code).replace("### UNIT CODE", unit_code)
+ code = TEST_TEMPLATE.replace("### USER CODE", user_code)
+ code = code.replace("### UNIT CODE", unit_code)
# Make sure that the code is well formatted (we don't check for the user code)
try:
diff --git a/tox.ini b/tox.ini
index 48a3da6..afb3b34 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,8 +1,10 @@
[flake8]
-max-line-length=88
+max-line-length=100
exclude=.cache,.venv,.git
docstring-convention=all
import-order-style=pycharm
ignore=
# Type annotations
ANN101,ANN102
+ # Line breaks
+ W503