Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
# - id: no-commit-to-branch

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v2.1.0'
rev: 'v2.3.0'
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -32,7 +32,7 @@ repos:
- sqlalchemy

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.15.20'
rev: 'v0.16.2'
hooks:
- id: ruff
args: [--fix]
Expand Down
1 change: 1 addition & 0 deletions src/routers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def _quality_clause(quality: str, range_: str | None) -> str:
@router.get(path="/list")
async def list_datasets( # noqa: PLR0913, C901
expdb_db: Annotated[AsyncSession, Depends(expdb_session)],
Comment thread
PGijsbers marked this conversation as resolved.
Outdated
*,
pagination: Annotated[Pagination, Body(default_factory=Pagination)],
data_name: Annotated[CasualString128 | None, Body()] = None,
tag: Annotated[TagString | None, Body()] = None,
Expand Down
1 change: 1 addition & 0 deletions src/routers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def _quality_clause(quality: str, range_: str | None) -> str:
@router.get(path="/list")
async def list_tasks( # noqa: PLR0913, PLR0912, C901, PLR0915
expdb: Annotated[AsyncSession, Depends(expdb_session)],
*,
Comment thread
PGijsbers marked this conversation as resolved.
pagination: Annotated[Pagination, Body(default_factory=Pagination)],
task_type_id: Annotated[Identifier | None, Body(description="Filter by task type id.")] = None,
tag: Annotated[TagString | None, Body()] = None,
Expand Down
10 changes: 5 additions & 5 deletions src/routers/tasktype.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
router = APIRouter(prefix="/tasktype", tags=["tasks"])


def _normalize_task_type(task_type: Row[Any]) -> dict[str, str | None | list[Any]]:
def _normalize_task_type(task_type: Row[Any]) -> dict[str, str | list[Any] | None]:
# Task types may contain multi-line fields which have either \r\n or \n line endings
ttype: dict[str, str | None | list[Any]] = {
ttype: dict[str, str | list[Any] | None] = {
k: str(v).replace("\r\n", "\n").strip() if v is not None else v
for k, v in task_type._mapping.items() # noqa: SLF001
if k != "id"
Expand All @@ -40,10 +40,10 @@ async def list_task_types(
expdb: Annotated[AsyncSession, Depends(expdb_session)],
) -> dict[
Literal["task_types"],
dict[Literal["task_type"], list[dict[str, str | None | list[Any]]]],
dict[Literal["task_type"], list[dict[str, str | list[Any] | None]]],
]:
"""Return a high level description of all task types."""
task_types: list[dict[str, str | None | list[Any]]] = [
task_types: list[dict[str, str | list[Any] | None]] = [
_normalize_task_type(ttype) for ttype in await get_task_types(expdb)
]
return {"task_types": {"task_type": task_types}}
Expand All @@ -53,7 +53,7 @@ async def list_task_types(
async def get_task_type(
task_type_id: Identifier,
expdb: Annotated[AsyncSession, Depends(expdb_session)],
) -> dict[Literal["task_type"], dict[str, str | None | list[str] | list[dict[str, str]]]]:
) -> dict[Literal["task_type"], dict[str, str | list[str] | list[dict[str, str]] | None]]:
"""Return a detailed description for the given task type, including expected inputs."""
task_type_record = await db_get_task_type(task_type_id, expdb)
if task_type_record is None:
Expand Down
9 changes: 8 additions & 1 deletion tests/routers/dataset_tag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,11 @@ async def test_dataset_tag_response_is_identical(
py_api: httpx.AsyncClient,
php_api: httpx.AsyncClient,
) -> None:
await assert_tag_response_is_identical(dataset_id, tag, api_key, "dataset", py_api, php_api)
await assert_tag_response_is_identical(
identifier=dataset_id,
tag=tag,
api_key=api_key,
entity="dataset",
py_api=py_api,
php_api=php_api,
)
2 changes: 1 addition & 1 deletion tests/routers/setups_tag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def test_setup_tag_direct_success(expdb_session: AsyncSession) -> None:
[[], ["some_other_tag"], ["foo_some_other_tag", "bar_some_other_tag"]],
ids=["none", "one tag", "two tags"],
)
async def test_setup_tag_response_is_identical_when_tag_doesnt_exist( # noqa: PLR0913
async def test_setup_tag_response_is_identical_when_tag_doesnt_exist( # noqa: PLR0913, PLR0917
api_key: str,
other_tags: list[str],
py_api: httpx.AsyncClient,
Expand Down
1 change: 1 addition & 0 deletions tests/routers/tag_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


async def assert_tag_response_is_identical( # noqa: PLR0913
*,
identifier: Identifier,
tag: str,
api_key: str,
Expand Down
4 changes: 3 additions & 1 deletion tests/routers/task_tag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ async def test_task_tag_response_is_identical(
py_api: httpx.AsyncClient,
php_api: httpx.AsyncClient,
) -> None:
await assert_tag_response_is_identical(task_id, tag, api_key, "task", py_api, php_api)
await assert_tag_response_is_identical(
identifier=task_id, tag=tag, api_key=api_key, entity="task", py_api=py_api, php_api=php_api
)
Loading