@@ -77,6 +77,10 @@ def __repr__(self):
77
77
return (f"{ self .__class__ .__name__ } (msgid={ self .msgid } , "
78
78
f"msgtype={ self .msgtype } { optional } )" )
79
79
80
+ def __rich_repr__ (self ):
81
+ yield "msgid" , self .msgid
82
+ yield "controls" , self .controls , None
83
+
80
84
81
85
class Result (Response ):
82
86
result : int
@@ -109,6 +113,13 @@ def __repr__(self):
109
113
return (f"{ self .__class__ .__name__ } "
110
114
f"(msgid={ self .msgid } , result={ self .result } { optional } )" )
111
115
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
+
112
123
113
124
class SearchEntry (Response ):
114
125
msgtype = ldap .RES_SEARCH_ENTRY
@@ -125,6 +136,11 @@ def __new__(cls, msgid, msgtype, controls=None, *,
125
136
126
137
return instance
127
138
139
+ def __rich_repr__ (self ):
140
+ super ().__rich_repr__ ()
141
+ yield "dn" , self .dn
142
+ yield "attrs" , self .attrs
143
+
128
144
129
145
class SearchReference (Response ):
130
146
msgtype = ldap .RES_SEARCH_REFERENCE
@@ -139,6 +155,10 @@ def __new__(cls, msgid, msgtype, controls=None, *,
139
155
140
156
return instance
141
157
158
+ def __rich_repr__ (self ):
159
+ super ().__rich_repr__ ()
160
+ yield "referrals" , self .referrals
161
+
142
162
143
163
class SearchResult (Result ):
144
164
msgtype = ldap .RES_SEARCH_RESULT
@@ -176,17 +196,30 @@ def __repr__(self):
176
196
optional += f", name={ self .name } "
177
197
if self .value is not None :
178
198
optional += f", value={ self .value } "
199
+ if self .message :
200
+ optional = f", message={ self .message !r} "
179
201
if self .controls is not None :
180
202
optional += f", controls={ self .controls } "
181
203
return (f"{ self .__class__ .__name__ } "
182
204
f"(msgid={ self .msgid } { optional } )" )
183
205
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
+
184
213
185
214
class BindResult (Result ):
186
215
msgtype = ldap .RES_BIND
187
216
188
217
servercreds : Optional [bytes ]
189
218
219
+ def __rich_repr__ (self ):
220
+ super ().__rich_repr__ ()
221
+ yield "servercreds" , self .servercreds , None
222
+
190
223
191
224
class ModifyResult (Result ):
192
225
msgtype = ldap .RES_MODIFY
@@ -264,6 +297,13 @@ def __repr__(self):
264
297
return (f"{ self .__class__ .__name__ } "
265
298
f"(msgid={ self .msgid } , result={ self .result } { optional } )" )
266
299
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
+
267
307
268
308
class UnsolicitedNotification (ExtendedResult ):
269
309
msgid = ldap .RES_UNSOLICITED
0 commit comments