Skip to content

Commit

Permalink
Improve list parser
Browse files Browse the repository at this point in the history
  • Loading branch information
srfwx committed Dec 5, 2024
1 parent 3df1bab commit a9cc782
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,10 @@ def list_parser(key_name, value):
value = [list_item_parser(item) for item in value]
else:
lookup = getattr(self.__class__, key_name, None)
if not isinstance(lookup, list):
# This is *list_parser*, so if the custom model field is not
# a list (or is not defined), just return the default model
value = [self.default_ret(i, self.api, None) for i in value]
else:
model = lookup[0]
value = [model(i, self.api, None) for i in value]
# This is *list_parser*, so if the custom model field is not
# a list (or is not defined), just return the default model
model = lookup[0] if isinstance(lookup, list) else self.default_ret
value = [model(i, self.api, None) for i in value]
return value, [*value]

def parse_value(key_name, value):
Expand Down

0 comments on commit a9cc782

Please sign in to comment.