From 9ea2c7c3a414c1ce2e3b25de7c4c126ea8554cf5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:42:16 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- platform_disk_api/kube_client.py | 6 +++--- platform_disk_api/service.py | 8 +++++--- tests/integration/conftest.py | 16 ++++++++-------- tests/integration/test_api.py | 6 ++---- tests/integration/test_kube_client.py | 4 ++-- tests/unit/test_pvc.py | 18 +++++++++--------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/platform_disk_api/kube_client.py b/platform_disk_api/kube_client.py index 5d09530..9bb69be 100644 --- a/platform_disk_api/kube_client.py +++ b/platform_disk_api/kube_client.py @@ -160,8 +160,8 @@ def from_primitive(cls, payload: dict[str, Any]) -> "PersistentVolumeClaimRead": payload["spec"]["resources"]["requests"]["storage"] ), storage_real=storage_real, - labels=payload["metadata"].get("labels", dict()), - annotations=payload["metadata"].get("annotations", dict()), + labels=payload["metadata"].get("labels", {}), + annotations=payload["metadata"].get("annotations", {}), ) @@ -494,7 +494,7 @@ async def list_pods(self) -> PodListResult: async def watch_pods( self, resource_version: Optional[str] = None ) -> AsyncIterator[PodWatchEvent]: - params = dict(watch="true", allowWatchBookmarks="true") + params = {"watch": "true", "allowWatchBookmarks": "true"} if resource_version: params["resourceVersion"] = resource_version url = self._pod_url diff --git a/platform_disk_api/service.py b/platform_disk_api/service.py index bb105b6..97e88bf 100644 --- a/platform_disk_api/service.py +++ b/platform_disk_api/service.py @@ -156,9 +156,11 @@ def _get_if_present( return Disk( id=pvc.name, - storage=pvc.storage_real - if pvc.storage_real is not None - else pvc.storage_requested, + storage=( + pvc.storage_real + if pvc.storage_real is not None + else pvc.storage_requested + ), status=status_map[pvc.phase], owner=username, project_name=pvc.labels.get(PROJECT_LABEL, username), diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index cedbaea..c2871dd 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -69,17 +69,17 @@ def config_factory( kube_client: None, # Force cleanup ) -> Callable[..., Config]: def _f(**kwargs: Any) -> Config: - defaults = dict( - server=ServerConfig(host="0.0.0.0", port=8080), - platform_auth=auth_config, - kube=kube_config, - cluster_name=cluster_name, - disk=DiskConfig( + defaults = { + "server": ServerConfig(host="0.0.0.0", port=8080), + "platform_auth": auth_config, + "kube": kube_config, + "cluster_name": cluster_name, + "disk": DiskConfig( k8s_storage_class=k8s_storage_class, storage_limit_per_user=1024 * 1024 * 20, # 20mb ), - cors=CORSConfig(allowed_origins=["https://neu.ro"]), - ) + "cors": CORSConfig(allowed_origins=["https://neu.ro"]), + } kwargs = {**defaults, **kwargs} return Config(**kwargs) diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 1058372..d0d29ad 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -70,8 +70,7 @@ async def disk_api(config: Config) -> AsyncIterator[DiskApiEndpoints]: class DiskGranter(Protocol): - async def __call__(self, user: _User, disk: Disk, action: str = "read") -> None: - ... + async def __call__(self, user: _User, disk: Disk, action: str = "read") -> None: ... @pytest.fixture @@ -94,8 +93,7 @@ async def _grant(user: _User, disk: Disk, action: str = "read") -> None: class ProjectGranter(Protocol): async def __call__( self, user: _User, project_name: str, action: str = "read" - ) -> None: - ... + ) -> None: ... @pytest.fixture diff --git a/tests/integration/test_kube_client.py b/tests/integration/test_kube_client.py index 0d1e592..1a8082d 100644 --- a/tests/integration/test_kube_client.py +++ b/tests/integration/test_kube_client.py @@ -231,7 +231,7 @@ async def test_create_with_labels( name=str(uuid4()), storage_class_name=k8s_storage_class, storage=10 * 1024 * 1024, # 10 mb - labels=dict(foo="bar"), + labels={"foo": "bar"}, ) await kube_client.create_pvc(pvc) pvcs = await kube_client.list_pvc() @@ -245,7 +245,7 @@ async def test_create_with_annotations( name=str(uuid4()), storage_class_name=k8s_storage_class, storage=10 * 1024 * 1024, # 10 mb - annotations=dict(foo="bar"), + annotations={"foo": "bar"}, ) await kube_client.create_pvc(pvc) pvcs = await kube_client.list_pvc() diff --git a/tests/unit/test_pvc.py b/tests/unit/test_pvc.py index 92ec958..f3ab615 100644 --- a/tests/unit/test_pvc.py +++ b/tests/unit/test_pvc.py @@ -52,7 +52,7 @@ def test_pvc_with_labels_to_primitive( name=name, storage_class_name=storage_class, storage=storage, - labels=dict(foo="bar"), + labels={"foo": "bar"}, ) assert pvc.to_primitive() == { "apiVersion": "v1", @@ -90,8 +90,8 @@ def test_pvc_from_primitive_pending( phase=PersistentVolumeClaimRead.Phase.PENDING, storage_requested=storage, storage_real=None, - labels=dict(), - annotations=dict(), + labels={}, + annotations={}, ) @pytest.mark.parametrize( @@ -157,8 +157,8 @@ def test_pvc_from_primitive_bound( phase=PersistentVolumeClaimRead.Phase.BOUND, storage_requested=storage, storage_real=2 * storage, - labels=dict(), - annotations=dict(), + labels={}, + annotations={}, ) @pytest.mark.parametrize("name,storage_class,storage", [("test", "test-stor", 100)]) @@ -185,8 +185,8 @@ def test_pvc_from_primitive_with_labels( phase=PersistentVolumeClaimRead.Phase.BOUND, storage_requested=storage, storage_real=2 * storage, - labels=dict(foo="bar"), - annotations=dict(), + labels={"foo": "bar"}, + annotations={}, ) @pytest.mark.parametrize("name,storage_class,storage", [("test", "test-stor", 100)]) @@ -213,6 +213,6 @@ def test_pvc_from_primitive_with_annotations( phase=PersistentVolumeClaimRead.Phase.BOUND, storage_requested=storage, storage_real=2 * storage, - labels=dict(), - annotations=dict(foo="bar"), + labels={}, + annotations={"foo": "bar"}, )