Skip to content

Commit

Permalink
Remove api.Literal
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Sella <[email protected]>
  • Loading branch information
inknos committed Dec 13, 2024
1 parent 966503f commit 995f760
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 0 additions & 2 deletions podman/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
)
from podman.api.tar_utils import create_tar, prepare_containerfile, prepare_containerignore

from typing import Literal

DEFAULT_CHUNK_SIZE = 2 * 1024 * 1024


Expand Down
8 changes: 4 additions & 4 deletions podman/domain/images.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Model and Manager for Image resources."""

import logging
from typing import Any, Optional, Union
from typing import Any, Optional, Literal, Union
from collections.abc import Iterator

import urllib.parse

from podman import api
from podman.api import DEFAULT_CHUNK_SIZE
from podman.domain.manager import PodmanResource
from podman.errors import ImageNotFound, InvalidArgument

Expand Down Expand Up @@ -50,7 +50,7 @@ def history(self) -> list[dict[str, Any]]:

def remove(
self, **kwargs
) -> list[dict[api.Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]:
) -> list[dict[Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]:
"""Delete image from Podman service.
Podman only
Expand All @@ -70,7 +70,7 @@ def remove(

def save(
self,
chunk_size: Optional[int] = api.DEFAULT_CHUNK_SIZE,
chunk_size: Optional[int] = DEFAULT_CHUNK_SIZE,
named: Union[str, bool] = False,
) -> Iterator[bytes]:
"""Returns Image as tarball.
Expand Down
11 changes: 5 additions & 6 deletions podman/domain/networks_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
import ipaddress
import logging
from contextlib import suppress
from typing import Any, Optional
from typing import Any, Optional, Literal

from podman import api
from podman.api import http_utils
from podman.api import http_utils, prepare_filters
from podman.domain.manager import Manager
from podman.domain.networks import Network
from podman.errors import APIError
Expand Down Expand Up @@ -152,7 +151,7 @@ def list(self, **kwargs) -> list[Network]:
filters = kwargs.get("filters", {})
filters["name"] = kwargs.get("names")
filters["id"] = kwargs.get("ids")
filters = api.prepare_filters(filters)
filters = prepare_filters(filters)

params = {"filters": filters}
response = self.client.get("/networks/json", params=params)
Expand All @@ -162,7 +161,7 @@ def list(self, **kwargs) -> list[Network]:

def prune(
self, filters: Optional[dict[str, Any]] = None
) -> dict[api.Literal["NetworksDeleted", "SpaceReclaimed"], Any]:
) -> dict[Literal["NetworksDeleted", "SpaceReclaimed"], Any]:
"""Delete unused Networks.
SpaceReclaimed always reported as 0
Expand All @@ -173,7 +172,7 @@ def prune(
Raises:
APIError: when service reports error
"""
params = {"filters": api.prepare_filters(filters)}
params = {"filters": prepare_filters(filters)}
response = self.client.post("/networks/prune", params=params)
response.raise_for_status()

Expand Down

0 comments on commit 995f760

Please sign in to comment.