diff --git a/darwin/future/core/items/set_item_layout.py b/darwin/future/core/items/set_item_layout.py index bd1efdab2..2a2a3a837 100644 --- a/darwin/future/core/items/set_item_layout.py +++ b/darwin/future/core/items/set_item_layout.py @@ -1,8 +1,11 @@ from __future__ import annotations +from typing import Dict + from darwin.future.core.client import ClientCore from darwin.future.core.types.common import JSONType from darwin.future.data_objects.item import ItemLayout +from darwin.future.data_objects.typing import UnknownType def set_item_layout( @@ -10,31 +13,30 @@ def set_item_layout( team_slug: str, dataset_ids: int | list[int], layout: ItemLayout, - params: JSONType, + filters: Dict[str, UnknownType], ) -> JSONType: """ - Set the layout of a dataset and filtered items via params. + Set the layout of a dataset and filtered items via filters. Args: client (ClientCore): The Darwin Core client. team_slug (str): The team slug. dataset_ids (int | list[int]): The dataset ids. layout (ItemLayout): The layout. - params (JSONType): The parameters. + filters Dict[str, UnknownType]: The parameters of the filter. Returns: JSONType: The response data. """ assert ( - params + filters ), "No parameters provided, please provide at least one non-dataset id filter" - assert isinstance(params, dict), "Parameters must be a dictionary of filters" payload = { "filters": { "dataset_ids": dataset_ids if isinstance(dataset_ids, list) else [dataset_ids], - **params, + **filters, }, "layout": dict(layout), } diff --git a/darwin/future/tests/core/items/test_set_item_layout.py b/darwin/future/tests/core/items/test_set_item_layout.py index 84e145bf9..8cca506ed 100644 --- a/darwin/future/tests/core/items/test_set_item_layout.py +++ b/darwin/future/tests/core/items/test_set_item_layout.py @@ -1,11 +1,13 @@ +from typing import Dict + import pytest import responses from requests import HTTPError from darwin.future.core.client import ClientCore from darwin.future.core.items.set_item_layout import set_item_layout -from darwin.future.core.types.common import JSONType from darwin.future.data_objects.item import ItemLayout +from darwin.future.data_objects.typing import UnknownType from darwin.future.tests.core.fixtures import * from darwin.future.tests.core.items.fixtures import * @@ -35,7 +37,7 @@ def test_set_item_layout_raises_on_incorrect_parameters( ) -> None: team_slug = "my_team" dataset_ids = [1, 2, 3] - params: JSONType = {} + params: Dict[str, UnknownType] = {} with pytest.raises(AssertionError): set_item_layout(base_client, team_slug, dataset_ids, base_layout, params)