Skip to content

Commit

Permalink
fix: Enhancement of __repr__ method (nautobot#67)
Browse files Browse the repository at this point in the history
Update `Record` class in pynautobot/core/response.py module.
Add more detailed info the `__repr__()` method returns.
  • Loading branch information
nautics889 authored and James Harr committed Jun 15, 2023
1 parent e2b165b commit 287862f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pynautobot/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ class Record(object):
:examples:
Default representation of the object is usually its name
Default representation of the object usually contains object's
class and object's name
>>> x = nb.dcim.devices.get(1)
>>> x
test1-switch1
<pynautobot.models.dcim.Devices object (name='test1-switch1')>
>>>
Querying a string field.
Expand Down Expand Up @@ -205,7 +206,7 @@ def __str__(self):
return getattr(self, "display", None) or getattr(self, "name", None) or getattr(self, "label", None) or ""

def __repr__(self):
return str(self)
return "<{}.{} object (name='{}')>".format(self.__class__.__module__, self.__class__.__name__, self)

def __getstate__(self):
return self.__dict__
Expand Down

0 comments on commit 287862f

Please sign in to comment.