From c4af68cb79894a88d9e354b907c2d75b20ebd16a Mon Sep 17 00:00:00 2001 From: jo Date: Fri, 20 Oct 2023 15:10:45 +0200 Subject: [PATCH] feat: prepare for iso deprecated field removal --- hcloud/isos/domain.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hcloud/isos/domain.py b/hcloud/isos/domain.py index 17676ec..5444c5a 100644 --- a/hcloud/isos/domain.py +++ b/hcloud/isos/domain.py @@ -1,6 +1,7 @@ from __future__ import annotations -from dateutil.parser import isoparse +from datetime import datetime +from warnings import warn from ..core import BaseDomain, DomainIdentityMixin from ..deprecation import DeprecationInfo @@ -32,7 +33,6 @@ class Iso(BaseDomain, DomainIdentityMixin): "type", "architecture", "description", - "deprecated", "deprecation", ) @@ -43,7 +43,7 @@ def __init__( type: str | None = None, architecture: str | None = None, description: str | None = None, - deprecated: str | None = None, + deprecated: str | None = None, # pylint: disable=unused-argument deprecation: dict | None = None, ): self.id = id @@ -51,7 +51,16 @@ def __init__( self.type = type self.architecture = architecture self.description = description - self.deprecated = isoparse(deprecated) if deprecated else None self.deprecation = ( DeprecationInfo.from_dict(deprecation) if deprecation is not None else None ) + + @property + def deprecated(self) -> datetime | None: + warn( + "The `deprecated` field is deprecated, please use the `deprecation` field instead.", + DeprecationWarning, + ) + if self.deprecation is None: + return None + return self.deprecation.unavailable_after