aboutsummaryrefslogtreecommitdiffstats
path: root/backend/models/form_response.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-07 02:29:26 +0100
committerGravatar Joe Banks <[email protected]>2024-07-08 15:00:10 +0100
commitd0e09d2ba567f23d91ac76d1844966bafb9b063a (patch)
tree9e825e3f09df02ab32e401c7e9555df26356dd4c /backend/models/form_response.py
parentChange linting config to Ruff (diff)
Apply fixable lint settings with Ruff
Diffstat (limited to 'backend/models/form_response.py')
-rw-r--r--backend/models/form_response.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/backend/models/form_response.py b/backend/models/form_response.py
index 933f5e4..3c8297b 100644
--- a/backend/models/form_response.py
+++ b/backend/models/form_response.py
@@ -11,19 +11,20 @@ class FormResponse(BaseModel):
"""Schema model for form response."""
id: str = Field(alias="_id")
- user: t.Optional[DiscordUser]
- antispam: t.Optional[AntiSpam]
+ user: DiscordUser | None
+ antispam: AntiSpam | None
response: dict[str, t.Any]
form_id: str
timestamp: str
@validator("timestamp", pre=True)
- def set_timestamp(cls, iso_string: t.Optional[str]) -> t.Optional[str]:
+ def set_timestamp(cls, iso_string: str | None) -> str:
if iso_string is None:
- return datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
+ return datetime.datetime.now(tz=datetime.UTC).isoformat()
- elif not isinstance(iso_string, str):
- raise ValueError("Submission timestamp must be a string.")
+ if not isinstance(iso_string, str):
+ msg = "Submission timestamp must be a string."
+ raise TypeError(msg)
# Convert to datetime and back to ensure string is valid
return datetime.datetime.fromisoformat(iso_string).isoformat()
@@ -33,4 +34,4 @@ class FormResponse(BaseModel):
class ResponseList(BaseModel):
- __root__: t.List[FormResponse]
+ __root__: list[FormResponse]