Skip to content

Commit

Permalink
fix: raise warnings for the ImagesClient.get_by_name deprecation (#376
Browse files Browse the repository at this point in the history
)

Add missing warning and sphinx deprecation notice on an already
deprecated method.
  • Loading branch information
jooola authored Apr 2, 2024
1 parent 2e9c5fc commit b24de80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hcloud/images/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
Expand Down Expand Up @@ -305,12 +306,19 @@ def get_all(
def get_by_name(self, name: str) -> BoundImage | None:
"""Get image by name
Deprecated: Use get_by_name_and_architecture instead.
:param name: str
Used to get image by name.
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
.. deprecated:: 1.19
Use :func:`hcloud.images.client.ImagesClient.get_by_name_and_architecture` instead.
"""
warnings.warn(
"The 'hcloud.images.client.ImagesClient.get_by_name' method is deprecated, please use the "
"'hcloud.images.client.ImagesClient.get_by_name_and_architecture' method instead.",
DeprecationWarning,
stacklevel=2,
)
return self._get_first_by(name=name)

def get_by_name_and_architecture(
Expand Down

0 comments on commit b24de80

Please sign in to comment.