diff --git a/hcloud/core/domain.py b/hcloud/core/domain.py index 21aed34..ec54ef3 100644 --- a/hcloud/core/domain.py +++ b/hcloud/core/domain.py @@ -2,15 +2,16 @@ class BaseDomain: - __slots__ = () + __slots__: tuple[str, ...] = () @classmethod def from_dict(cls, data: dict): # type: ignore[no-untyped-def] + """Convert a dict to domain object.""" supported_data = {k: v for k, v in data.items() if k in cls.__slots__} return cls(**supported_data) def __repr__(self) -> str: - kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__slots__] # type: ignore[var-annotated] + kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__slots__] return f"{self.__class__.__qualname__}({', '.join(kwargs)})" @@ -24,10 +25,9 @@ class DomainIdentityMixin: def id_or_name(self) -> int | str: if self.id is not None: return self.id - elif self.name is not None: + if self.name is not None: return self.name - else: - raise ValueError("id or name must be set") + raise ValueError("id or name must be set") class Pagination(BaseDomain):