Skip to content

Commit

Permalink
Simplifies get_return
Browse files Browse the repository at this point in the history
  • Loading branch information
srfwx committed Dec 5, 2024
1 parent 0f9e41b commit 1f61ece
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down

0 comments on commit 1f61ece

Please sign in to comment.