From 8b8ed4c99b076b4be3ae6c584091f28b7b6e1405 Mon Sep 17 00:00:00 2001 From: Peder Hovdan Andresen <107681714+pederhan@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:08:36 +0100 Subject: [PATCH] feat: add `DictModel.items()`. (#257) --- zabbix_cli/pyzabbix/types.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zabbix_cli/pyzabbix/types.py b/zabbix_cli/pyzabbix/types.py index c119e4da..94715b15 100644 --- a/zabbix_cli/pyzabbix/types.py +++ b/zabbix_cli/pyzabbix/types.py @@ -19,6 +19,7 @@ from typing import TYPE_CHECKING from typing import Any from typing import Dict +from typing import Iterable from typing import List from typing import MutableMapping from typing import Optional @@ -409,11 +410,12 @@ class DictModel(ZabbixAPIBaseModel): model_config = ConfigDict(extra="allow") + def items(self) -> Iterable[tuple[str, Any]]: + return self.model_dump(mode="python").items() + def __cols_rows__(self) -> ColsRowsType: cols = ["Key", "Value"] - rows: RowsType = [ - [key, str(value)] for key, value in self.model_dump().items() if value - ] + rows: RowsType = [[key, str(value)] for key, value in self.items() if value] return cols, rows