Skip to content

Commit 5d4b713

Browse files
authored
fix: Add missing typing for already typed functions (#2451)
1 parent 7f766ac commit 5d4b713

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+243
-257
lines changed

class_generator/class_generator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import ast
42
import filecmp
53
import json
@@ -143,7 +141,7 @@ def read_resources_mapping_file() -> dict[Any, Any]:
143141
return {}
144142

145143

146-
def get_server_version(client: str):
144+
def get_server_version(client: str) -> str:
147145
rc, out, _ = run_command(command=shlex.split(f"{client} version -o json"), check=False)
148146
if not rc:
149147
LOGGER.error("Failed to get server version")

ocp_resources/application_aware_cluster_resource_quota.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# API reference: https://github.com/kubevirt/application-aware-quota/tree/main/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core/v1alpha1
22
# TODO: update API reference when OCP doc is available
3-
from __future__ import annotations
4-
from typing import Dict, Any
3+
from typing import Any
54

65
from ocp_resources.resource import MissingRequiredArgumentError, Resource
76

@@ -11,8 +10,8 @@ class ApplicationAwareClusterResourceQuota(Resource):
1110

1211
def __init__(
1312
self,
14-
quota: Dict[str, Any] | None = None,
15-
selector: Dict[str, Any] | None = None,
13+
quota: dict[str, Any] | None = None,
14+
selector: dict[str, Any] | None = None,
1615
**kwargs: Any,
1716
) -> None:
1817
"""

ocp_resources/application_aware_resource_quota.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# API reference: https://github.com/kubevirt/application-aware-quota/tree/main/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core/v1alpha1
22
# TODO: update API reference when OCP doc is available
3-
from __future__ import annotations
4-
from typing import Dict, Any, List
3+
from typing import Any
54

65
from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource
76

@@ -11,9 +10,9 @@ class ApplicationAwareResourceQuota(NamespacedResource):
1110

1211
def __init__(
1312
self,
14-
hard: Dict[str, Any] | None = None,
15-
scope_selector: Dict[str, Any] | None = None,
16-
scopes: List[str] | None = None,
13+
hard: dict[str, Any] | None = None,
14+
scope_selector: dict[str, Any] | None = None,
15+
scopes: list[str] | None = None,
1716
**kwargs: Any,
1817
) -> None:
1918
"""

ocp_resources/backup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import annotations
3-
from typing import Any, List
2+
from typing import Any
43

54
from ocp_resources.resource import NamespacedResource
65

@@ -15,8 +14,8 @@ class Backup(NamespacedResource):
1514

1615
def __init__(
1716
self,
18-
included_namespaces: List[str] | None = None,
19-
excluded_resources: List[str] | None = None,
17+
included_namespaces: list[str] | None = None,
18+
excluded_resources: list[str] | None = None,
2019
snapshot_move_data: bool = False,
2120
storage_location: str = "",
2221
**kwargs: Any,

ocp_resources/benchmark.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

3-
from ocp_resources.utils.constants import NOT_FOUND_ERROR_EXCEPTION_DICT, TIMEOUT_30SEC
4-
from ocp_resources.resource import NamespacedResource
53
from timeout_sampler import TimeoutSampler
64

5+
from ocp_resources.resource import NamespacedResource
6+
from ocp_resources.utils.constants import NOT_FOUND_ERROR_EXCEPTION_DICT, TIMEOUT_30SEC
7+
78

89
class Benchmark(NamespacedResource):
910
"""
@@ -75,7 +76,7 @@ def workload_kind(self) -> str:
7576
"""
7677
return self.workload_arg(arg="kind", default="pod")
7778

78-
def workload_arg(self, arg: str, default: Optional[Any] = None) -> Any:
79+
def workload_arg(self, arg: str, default: Any = None) -> Any:
7980
"""
8081
Retrieve the value of spec.workload.args[arg]
8182

ocp_resources/cdi_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
22

3-
from __future__ import annotations
4-
from __future__ import annotations
53
from typing import Any
6-
from ocp_resources.utils.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
7-
from ocp_resources.resource import Resource
4+
85
from timeout_sampler import TimeoutSampler
96

7+
from ocp_resources.resource import Resource
8+
from ocp_resources.utils.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
9+
1010

1111
class CDIConfig(Resource):
1212
"""

ocp_resources/chaos_engine.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
from typing import Any, Dict, List
3+
from typing import Any
4+
45
from ocp_resources.resource import NamespacedResource
56

67

@@ -17,8 +18,8 @@ def engine_status(self) -> str:
1718
return self.instance.status["engineStatus"]
1819

1920
@property
20-
def experiments_status(self) -> Dict[str, Dict[str, Any]]:
21-
experiments: List[Dict[Any, Any]] = self.instance.status["experiments"]
21+
def experiments_status(self) -> dict[str, dict[str, Any]]:
22+
experiments: list[dict[Any, Any]] = self.instance.status["experiments"]
2223
ret_value = {}
2324
for experiment in experiments:
2425
exp = {"verdict": experiment["verdict"], "status": experiment["status"]}

ocp_resources/cluster_deployment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Dict
1+
from typing import Any
2+
23
from ocp_resources.resource import NamespacedResource
34

45

@@ -13,8 +14,8 @@ def __init__(
1314
self,
1415
base_domain: str = "",
1516
cluster_name: str = "",
16-
platform: Dict[str, Any] | None = None,
17-
provisioning: Dict[str, Any] | None = None,
17+
platform: dict[str, Any] | None = None,
18+
provisioning: dict[str, Any] | None = None,
1819
pull_secret_ref_name: str = "",
1920
**kwargs: Any,
2021
) -> None:

ocp_resources/cluster_pool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from __future__ import annotations
2-
from typing import Any, Dict
1+
from typing import Any
2+
33
from ocp_resources.resource import NamespacedResource
44

55

@@ -14,7 +14,7 @@ def __init__(
1414
self,
1515
base_domain: str = "",
1616
image_set_ref_name: str = "",
17-
platform: Dict[str, Any] | None = None,
17+
platform: dict[str, Any] | None = None,
1818
pull_secret_ref_name: str = "",
1919
running_count: int | None = None,
2020
size: int | None = None,

ocp_resources/cluster_service_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import List, Any, Dict
2+
from typing import Any
33

44
from ocp_resources.resource import NamespacedResource
55

@@ -10,13 +10,13 @@ class ClusterServiceVersion(NamespacedResource):
1010
class Status(NamespacedResource.Status):
1111
INSTALLING = "Installing"
1212

13-
def get_alm_examples(self) -> List[Dict[str, Any]]:
13+
def get_alm_examples(self) -> list[dict[str, Any]]:
1414
"""
1515
Parse the alm-examples annotation from the CSV instance and return a list of dictionaries.
1616
Returns an empty list if no annotation is found or if the JSON is invalid.
1717
1818
Returns:
19-
Union[List[Dict[str, Any]], List[]]: A list of dictionaries from alm-examples, or an empty list if parsing fails.
19+
Union[List[dict[str, Any]], List[]]: A list of dictionaries from alm-examples, or an empty list if parsing fails.
2020
"""
2121
alm_examples = self.instance.metadata.annotations.get("alm-examples")
2222

0 commit comments

Comments
 (0)