Skip to content

Commit 6418c82

Browse files
committed
feat: renamed ClientEntityBase to BaseResourceClient
1 parent 9096813 commit 6418c82

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

hcloud/core/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from __future__ import annotations
22

3-
from .client import BoundModelBase, ClientEntityBase
3+
from .client import BaseResourceClient, BoundModelBase, ClientEntityBase
44
from .domain import BaseDomain, DomainIdentityMixin, Meta, Pagination
55

66
__all__ = [
7+
"BaseDomain",
8+
"BaseResourceClient",
79
"BoundModelBase",
810
"ClientEntityBase",
9-
"BaseDomain",
1011
"DomainIdentityMixin",
1112
"Meta",
1213
"Pagination",

hcloud/core/client.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from __future__ import annotations
22

3+
import warnings
34
from typing import TYPE_CHECKING, Any, Callable
45

56
if TYPE_CHECKING:
67
from .._client import Client
78

89

9-
class ClientEntityBase:
10+
class BaseResourceClient:
1011
_client: Client
1112

1213
max_per_page: int = 50
@@ -50,6 +51,24 @@ def _get_first_by(self, **kwargs): # type: ignore[no-untyped-def]
5051
return entities[0] if entities else None
5152

5253

54+
class ClientEntityBase(BaseResourceClient):
55+
"""
56+
Kept for backward compatibility.
57+
58+
.. deprecated:: 2.6.0
59+
Use :class:``hcloud.core.client.BaseResourceClient`` instead.
60+
"""
61+
62+
def __init__(self, client: Client):
63+
warnings.warn(
64+
"The 'hcloud.core.client.ClientEntityBase' class is deprecated, please use the "
65+
"'hcloud.core.client.BaseResourceClient' class instead.",
66+
DeprecationWarning,
67+
stacklevel=2,
68+
)
69+
super().__init__(client)
70+
71+
5372
class BoundModelBase:
5473
"""Bound Model Base"""
5574

tests/unit/core/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88
from hcloud.actions import ActionsPageResult
9-
from hcloud.core import BaseDomain, BoundModelBase, ClientEntityBase, Meta
9+
from hcloud.core import BaseDomain, BaseResourceClient, BoundModelBase, Meta
1010

1111

1212
class TestBoundModelBase:
@@ -99,15 +99,15 @@ def test_equality(self, bound_model_class, client):
9999
assert bound_model_a != bound_model_b.data_model
100100

101101

102-
class TestClientEntityBase:
102+
class TestBaseResourceClient:
103103
@pytest.fixture()
104104
def client_class_constructor(self):
105105
def constructor(json_content_function):
106106
class CandiesPageResult(NamedTuple):
107107
candies: list[Any]
108108
meta: Meta
109109

110-
class CandiesClient(ClientEntityBase):
110+
class CandiesClient(BaseResourceClient):
111111
def get_list(self, status=None, page=None, per_page=None):
112112
json_content = json_content_function(page)
113113
results = [
@@ -122,7 +122,7 @@ def get_list(self, status=None, page=None, per_page=None):
122122
@pytest.fixture()
123123
def client_class_with_actions_constructor(self):
124124
def constructor(json_content_function):
125-
class CandiesClient(ClientEntityBase):
125+
class CandiesClient(BaseResourceClient):
126126
def get_actions_list(self, status, page=None, per_page=None):
127127
json_content = json_content_function(page)
128128
results = [

0 commit comments

Comments
 (0)