Skip to content

Commit 0c5ec5b

Browse files
inknosMr-Sunglasses
authored andcommitted
Fix Code based on ruff 0.3->0.8.1
Fix errors for tyope annotation for list, dict, type and tuple Example: UP006: Use `list` instead of `List` for type annotation Signed-off-by: Nicola Sella <nsella@redhat.com>
1 parent eacbb79 commit 0c5ec5b

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

podman/domain/containers_create.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def create(
247247
in case of read_only options set to True. Default: False
248248
remove (bool): Remove the container when it has finished running. Default: False.
249249
restart_policy (dict[str, Union[str, int]]): Restart the container when it exits.
250+
250251
Configured as a dictionary with keys:
251252
252253
- Name: One of on-failure, or always.

podman/domain/images_manager.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
import logging
77
import os
88
import urllib.parse
9+
<<<<<<< HEAD
910
from typing import Any, Literal, Optional, Union
11+
=======
12+
from typing import Any, Optional, Union
13+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
1014
from collections.abc import Iterator, Mapping, Generator
1115
from pathlib import Path
1216
import requests
@@ -49,7 +53,11 @@ def exists(self, key: str) -> bool:
4953
response = self.client.get(f"/images/{key}/exists")
5054
return response.ok
5155

56+
<<<<<<< HEAD
5257
def list(self, **kwargs) -> builtins.list[Image]:
58+
=======
59+
def list(self, **kwargs) -> list[Image]:
60+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
5361
"""Report on images.
5462
5563
Keyword Args:
@@ -203,8 +211,13 @@ def prune(
203211
response = self.client.post("/images/prune", params=params)
204212
response.raise_for_status()
205213

214+
<<<<<<< HEAD
206215
deleted: builtins.list[dict[str, str]] = []
207216
error: builtins.list[str] = []
217+
=======
218+
deleted: list[dict[str, str]] = []
219+
error: list[str] = []
220+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
208221
reclaimed: int = 0
209222
# If the prune doesn't remove images, the API returns "null"
210223
# and it's interpreted as None (NoneType)
@@ -302,7 +315,11 @@ def push(
302315

303316
@staticmethod
304317
def _push_helper(
318+
<<<<<<< HEAD
305319
decode: bool, body: builtins.list[dict[str, Any]]
320+
=======
321+
decode: bool, body: list[dict[str, Any]]
322+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
306323
) -> Iterator[Union[str, dict[str, Any]]]:
307324
"""Helper needed to allow push() to return either a generator or a str."""
308325
for entry in body:
@@ -318,7 +335,11 @@ def pull(
318335
tag: Optional[str] = None,
319336
all_tags: bool = False,
320337
**kwargs,
338+
<<<<<<< HEAD
321339
) -> Union[Image, builtins.list[Image], Iterator[str]]:
340+
=======
341+
) -> Union[Image, list[Image], Iterator[str]]:
342+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
322343
"""Request Podman service to pull image(s) from repository.
323344
324345
Args:
@@ -423,7 +444,11 @@ def pull(
423444
for item in reversed(list(response.iter_lines())):
424445
obj = json.loads(item)
425446
if all_tags and "images" in obj:
447+
<<<<<<< HEAD
426448
images: builtins.list[Image] = []
449+
=======
450+
images: list[Image] = []
451+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
427452
for name in obj["images"]:
428453
images.append(self.get(name))
429454
return images
@@ -468,7 +493,11 @@ def remove(
468493
image: Union[Image, str],
469494
force: Optional[bool] = None,
470495
noprune: bool = False, # pylint: disable=unused-argument
496+
<<<<<<< HEAD
471497
) -> builtins.list[dict[Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]:
498+
=======
499+
) -> list[dict[Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]:
500+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
472501
"""Delete image from Podman service.
473502
474503
Args:
@@ -487,15 +516,23 @@ def remove(
487516
response.raise_for_status(not_found=ImageNotFound)
488517

489518
body = response.json()
519+
<<<<<<< HEAD
490520
results: builtins.list[dict[str, Union[int, str]]] = []
521+
=======
522+
results: list[dict[str, Union[int, str]]] = []
523+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
491524
for key in ("Deleted", "Untagged", "Errors"):
492525
if key in body:
493526
for element in body[key]:
494527
results.append({key: element})
495528
results.append({"ExitCode": body["ExitCode"]})
496529
return results
497530

531+
<<<<<<< HEAD
498532
def search(self, term: str, **kwargs) -> builtins.list[dict[str, Any]]:
533+
=======
534+
def search(self, term: str, **kwargs) -> list[dict[str, Any]]:
535+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
499536
"""Search Images on registries.
500537
501538
Args:

podman/domain/pods_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def prune(self, filters: Optional[dict[str, str]] = None) -> dict[str, Any]:
101101
response.raise_for_status()
102102

103103
deleted: builtins.list[str] = []
104+
104105
for item in response.json():
105106
if item["Err"] is not None:
106107
raise APIError(
@@ -132,7 +133,7 @@ def remove(self, pod_id: Union[Pod, str], force: Optional[bool] = None) -> None:
132133
response.raise_for_status()
133134

134135
def stats(
135-
self, **kwargs
136+
self, **kwargs
136137
) -> Union[builtins.list[dict[str, Any]], Iterator[builtins.list[dict[str, Any]]]]:
137138
"""Resource usage statistics for the containers in pods.
138139

podman/errors/exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""Podman API Errors."""
22

3+
<<<<<<< HEAD
34
from typing import List, Dict, Optional, Union, TYPE_CHECKING
5+
=======
6+
from typing import Optional, Union, TYPE_CHECKING
7+
>>>>>>> fa8eb3e (Fix Code based on ruff 0.3->0.8.1)
48
from collections.abc import Iterable
59

610
from requests import Response
@@ -143,7 +147,7 @@ def __init__(
143147

144148
class InvalidArgument(PodmanError):
145149
"""Parameter to method/function was not valid."""
146-
150+
147151

148152
class PodmanConnectionError(PodmanError):
149153
"""Exception raised when connection to Podman service fails using environment configuration."""

0 commit comments

Comments
 (0)