Skip to content

Commit

Permalink
changes from comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ychiucco committed Jan 14, 2025
1 parent 955d665 commit b574106
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fractal_server/app/schemas/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from typing import Any
from typing import Optional

from fractal_server.images.models import AttributeFiltersType


def valstr(attribute: str, accept_none: bool = False):
"""
Expand Down Expand Up @@ -104,8 +106,8 @@ def val(must_be_unique: Optional[list]) -> Optional[list]:


def validate_type_filters(
type_filters: Optional[dict],
) -> Optional[dict[str, bool]]:
type_filters: Optional[dict[str, bool]]
) -> dict[str, bool]:
if type_filters is None:
raise ValueError("'type_filters' cannot be 'None'.")

Expand All @@ -114,8 +116,8 @@ def validate_type_filters(


def validate_attribute_filters(
attribute_filters: Optional[dict[str, Optional[list[Any]]]],
) -> dict[str, Optional[list[Any]]]:
attribute_filters: Optional[AttributeFiltersType],
) -> AttributeFiltersType:
if attribute_filters is None:
raise ValueError("'attribute_filters' cannot be 'None'.")

Expand Down Expand Up @@ -147,6 +149,10 @@ def validate_attribute_filters(


def root_validate_dict_keys(cls, object: dict) -> dict:
"""
For each dictionary in `object.values()`,
checks that that dictionary has only keys of type str.
"""
for dictionary in (v for v in object.values() if isinstance(v, dict)):
if not all(isinstance(key, str) for key in dictionary.keys()):
raise ValueError("Dictionary keys must be strings.")
Expand Down

0 comments on commit b574106

Please sign in to comment.