Skip to content

Commit b24de80

Browse files
authored
fix: raise warnings for the ImagesClient.get_by_name deprecation (#376)
Add missing warning and sphinx deprecation notice on an already deprecated method.
1 parent 2e9c5fc commit b24de80

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

hcloud/images/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

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

56
from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
@@ -305,12 +306,19 @@ def get_all(
305306
def get_by_name(self, name: str) -> BoundImage | None:
306307
"""Get image by name
307308
308-
Deprecated: Use get_by_name_and_architecture instead.
309-
310309
:param name: str
311310
Used to get image by name.
312311
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
312+
313+
.. deprecated:: 1.19
314+
Use :func:`hcloud.images.client.ImagesClient.get_by_name_and_architecture` instead.
313315
"""
316+
warnings.warn(
317+
"The 'hcloud.images.client.ImagesClient.get_by_name' method is deprecated, please use the "
318+
"'hcloud.images.client.ImagesClient.get_by_name_and_architecture' method instead.",
319+
DeprecationWarning,
320+
stacklevel=2,
321+
)
314322
return self._get_first_by(name=name)
315323

316324
def get_by_name_and_architecture(

0 commit comments

Comments
 (0)