From 1f61ece629956a7374c010a2d416e1c6fa5e9f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Flagothier?= <29896153+srfwx@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:27:28 +0100 Subject: [PATCH] Simplifies get_return --- pynetbox/core/response.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pynetbox/core/response.py b/pynetbox/core/response.py index b329cdd..9068fd5 100644 --- a/pynetbox/core/response.py +++ b/pynetbox/core/response.py @@ -17,7 +17,6 @@ import marshal from collections import OrderedDict -import pynetbox.core.app from pynetbox.core.query import Request from pynetbox.core.util import Hashabledict @@ -29,16 +28,7 @@ def get_return(record): """ Used to return a "simple" representation of objects and collections. """ - return_fields = ["id", "value"] - - if not isinstance(record, Record): - raise ValueError - - for i in return_fields: - if value := getattr(record, i, None): - return value - else: - return str(record) + return getattr(record, "id", None) or getattr(record, "value", None) or str(record) def flatten_custom(custom_dict):