Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
e-lo committed Oct 16, 2024
1 parent 79a3da1 commit 9d1ca05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default_stages: [commit]
default_stages: [pre-commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Because of the necessary structure of the json-schema-based definition of projec
}
}
validated_road_selection = SelectRoadLinks(road_selection).model_dump()
```
```
8 changes: 5 additions & 3 deletions projectcard/models/_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated, Any, ClassVar, List, Union
from typing import Annotated, Any, ClassVar, Union

from pydantic import BaseModel, ConfigDict, Field, model_validator

Expand Down Expand Up @@ -179,7 +179,9 @@ def _check_one_or_one_superset_present(
"""Checks that exactly one of the fields in mixed_list is in fields_present or one superset."""
normalized_list = _normalize_to_lists(mixed_list)

list_items_present = [i for i in normalized_list if set(i).issubset(all_fields_present)]
list_items_present: list[Union[str, list[str]]] = [
i for i in normalized_list if set(i).issubset(all_fields_present)
]

if len(list_items_present) == 1:
return True
Expand Down Expand Up @@ -208,7 +210,7 @@ def _list_elements_subset_of_single_element(mixed_list: list[Union[str, list[str
return len(valid_supersets) == 1


def _normalize_to_lists(mixed_list: list[Union[str, list]]) -> list[list]:
def _normalize_to_lists(mixed_list: list[Union[str, list]]) -> list[list[str]]:
"""Turn a mixed list of scalars and lists into a list of lists."""
normalized_list = []
for item in mixed_list:
Expand Down

0 comments on commit 9d1ca05

Please sign in to comment.