Skip to content

Commit 8e390fe

Browse files
authored
fix: return type Self for functions that return self (#2468)
1 parent d190b7a commit 8e390fe

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

class_generator/class_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def get_client_binary() -> str:
636636
sys.exit(1)
637637

638638

639-
def update_kind_schema():
639+
def update_kind_schema() -> None:
640640
openapi2jsonschema_str: str = "openapi2jsonschema"
641641
client = get_client_binary()
642642

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from class_generator.scripts.tools import get_generated_files
22

33

4-
def test_get_generated_files():
4+
def test_get_generated_files() -> None:
55
_files: dict[str, dict[str, str]] = get_generated_files()
66
for _key in ("with_end_comment", "without_end_comment", "not_generated"):
77
assert _files.get(_key), f"{_key} is missing in generated files"

ocp_resources/project_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def to_dict(self) -> None:
4545

4646
# End of generated code
4747

48-
def deploy(self, wait: bool = False) -> Project:
48+
def deploy(self, wait: bool = False) -> Project: # type: ignore[override]
4949
super().deploy(wait=wait)
5050

5151
project = Project(

ocp_resources/resource.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from io import StringIO
1212
from signal import SIGINT, signal
1313
from types import TracebackType
14-
from typing import Any, Type
14+
from typing import Any, Self, Type
1515
from urllib.parse import parse_qs, urlencode, urlparse
1616

1717
import jsonschema
@@ -752,7 +752,7 @@ def _sigint_handler(self, signal_received: int, frame: Any) -> None:
752752
self.__exit__()
753753
sys.exit(signal_received)
754754

755-
def deploy(self, wait: bool = False) -> "Resource | NamespacedResource":
755+
def deploy(self, wait: bool = False) -> Self:
756756
"""
757757
For debug, export REUSE_IF_RESOURCE_EXISTS to skip resource create.
758758
Spaces are important in the export dict
@@ -1734,7 +1734,7 @@ def update(self, backup_resources: bool = False) -> None:
17341734
def restore(self) -> None:
17351735
self._apply_patches_sampler(patches=self._backups, action_text="Restoring", action=self.action)
17361736

1737-
def __enter__(self) -> "ResourceEditor":
1737+
def __enter__(self) -> Self:
17381738
self.update(backup_resources=True)
17391739
return self
17401740

@@ -1863,11 +1863,11 @@ class BaseResourceList(ABC):
18631863
iteration, indexing, deployment, and cleanup operations.
18641864
"""
18651865

1866-
def __init__(self, client: DynamicClient):
1866+
def __init__(self, client: DynamicClient) -> None:
18671867
self.resources: list[Resource] = []
18681868
self.client = client
18691869

1870-
def __enter__(self):
1870+
def __enter__(self) -> Self:
18711871
"""Enters the runtime context and deploys all resources."""
18721872
self.deploy()
18731873
return self

0 commit comments

Comments
 (0)