@@ -77,6 +77,10 @@ def __repr__(self):
7777 return (f"{ self .__class__ .__name__ } (msgid={ self .msgid } , "
7878 f"msgtype={ self .msgtype } { optional } )" )
7979
80+ def __rich_repr__ (self ):
81+ yield "msgid" , self .msgid
82+ yield "controls" , self .controls , None
83+
8084
8185class Result (Response ):
8286 result : int
@@ -109,6 +113,13 @@ def __repr__(self):
109113 return (f"{ self .__class__ .__name__ } "
110114 f"(msgid={ self .msgid } , result={ self .result } { optional } )" )
111115
116+ def __rich_repr__ (self ):
117+ super ().__rich_repr__ ()
118+ yield "result" , self .result
119+ yield "matcheddn" , self .matcheddn , ""
120+ yield "message" , self .message , ""
121+ yield "referrals" , self .referrals , None
122+
112123
113124class SearchEntry (Response ):
114125 msgtype = ldap .RES_SEARCH_ENTRY
@@ -125,6 +136,11 @@ def __new__(cls, msgid, msgtype, controls=None, *,
125136
126137 return instance
127138
139+ def __rich_repr__ (self ):
140+ super ().__rich_repr__ ()
141+ yield "dn" , self .dn
142+ yield "attrs" , self .attrs
143+
128144
129145class SearchReference (Response ):
130146 msgtype = ldap .RES_SEARCH_REFERENCE
@@ -139,6 +155,10 @@ def __new__(cls, msgid, msgtype, controls=None, *,
139155
140156 return instance
141157
158+ def __rich_repr__ (self ):
159+ super ().__rich_repr__ ()
160+ yield "referrals" , self .referrals
161+
142162
143163class SearchResult (Result ):
144164 msgtype = ldap .RES_SEARCH_RESULT
@@ -176,17 +196,30 @@ def __repr__(self):
176196 optional += f", name={ self .name } "
177197 if self .value is not None :
178198 optional += f", value={ self .value } "
199+ if self .message :
200+ optional = f", message={ self .message !r} "
179201 if self .controls is not None :
180202 optional += f", controls={ self .controls } "
181203 return (f"{ self .__class__ .__name__ } "
182204 f"(msgid={ self .msgid } { optional } )" )
183205
206+ def __rich_repr__ (self ):
207+ # No super(), we put our values between msgid and controls
208+ yield "msgid" , self .msgid
209+ yield "name" , self .name , None
210+ yield "value" , self .value , None
211+ yield "controls" , self .controls , None
212+
184213
185214class BindResult (Result ):
186215 msgtype = ldap .RES_BIND
187216
188217 servercreds : Optional [bytes ]
189218
219+ def __rich_repr__ (self ):
220+ super ().__rich_repr__ ()
221+ yield "servercreds" , self .servercreds , None
222+
190223
191224class ModifyResult (Result ):
192225 msgtype = ldap .RES_MODIFY
@@ -264,6 +297,13 @@ def __repr__(self):
264297 return (f"{ self .__class__ .__name__ } "
265298 f"(msgid={ self .msgid } , result={ self .result } { optional } )" )
266299
300+ def __rich_repr__ (self ):
301+ # No super(), we put our values between msgid and controls
302+ yield "msgid" , self .msgid
303+ yield "name" , self .name , None
304+ yield "value" , self .value , None
305+ yield "controls" , self .controls , None
306+
267307
268308class UnsolicitedNotification (ExtendedResult ):
269309 msgid = ldap .RES_UNSOLICITED
0 commit comments