diff options
author | 2020-12-16 10:28:52 +0000 | |
---|---|---|
committer | 2020-12-16 10:28:52 +0000 | |
commit | 2c5610d1dbf5d6e8fb112d9dc4d93330a87c6708 (patch) | |
tree | 78b7f2269ef04da0f9c3f871ac45a00cf14ca3f6 /backend/models/form.py | |
parent | Merge pull request #33 from python-discord/renovate/uvicorn-0.x (diff) | |
parent | Merge branch 'main' into ks123/routes-parsing (diff) |
Merge pull request #28 from python-discord/ks123/routes-parsing
Diffstat (limited to 'backend/models/form.py')
-rw-r--r-- | backend/models/form.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/backend/models/form.py b/backend/models/form.py index 2cf8486..cb58065 100644 --- a/backend/models/form.py +++ b/backend/models/form.py @@ -12,8 +12,8 @@ class Form(BaseModel): """Schema model for form.""" id: str = Field(alias="_id") - features: t.List[str] - questions: t.List[Question] + features: list[str] + questions: list[Question] name: str description: str @@ -21,12 +21,12 @@ class Form(BaseModel): allow_population_by_field_name = True @validator("features") - def validate_features(cls, value: t.List[str]) -> t.Optional[t.List[str]]: + def validate_features(cls, value: list[str]) -> t.Optional[list[str]]: """Validates is all features in allowed list.""" # Uppercase everything to avoid mixed case in DB value = [v.upper() for v in value] - allowed_values = list(v.value for v in FormFeatures.__members__.values()) - if not all(v in allowed_values for v in value): + allowed_values = [v.value for v in FormFeatures.__members__.values()] + 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 @@ -34,7 +34,7 @@ class Form(BaseModel): return value - def dict(self, admin: bool = True, **kwargs: t.Dict) -> t.Dict[str, t.Any]: + def dict(self, admin: bool = True, **kwargs: t.Any) -> dict[str, t.Any]: """Wrapper for original function to exclude private data for public access.""" data = super().dict(**kwargs) |