@@ -60,6 +60,12 @@ def __call__(self, obj, level):
60
60
61
61
62
62
class Serializable (object ): # pylint: disable=too-few-public-methods
63
+ _MARKDOWN_RESULT_STRING_CLASSES = (
64
+ CryptoDataParamsBase ,
65
+ ipaddress .IPv4Network ,
66
+ ipaddress .IPv6Network ,
67
+ urllib3 .util .url .Url ,
68
+ )
63
69
post_text_encoder = SerializableTextEncoder ()
64
70
65
71
@staticmethod
@@ -239,12 +245,12 @@ def _markdown_result(cls, obj, level=0): # pylint: disable=too-many-branches
239
245
return cls .post_text_encoder (obj .value , level )
240
246
241
247
return cls .post_text_encoder (obj .name , level )
242
- elif isinstance (obj , (ipaddress .IPv4Network , ipaddress .IPv6Network , urllib3 .util .url .Url )):
248
+ elif attr .has (type (obj )):
249
+ result = cls ._markdown_result_complex (obj , level )
250
+ elif isinstance (obj , cls ._MARKDOWN_RESULT_STRING_CLASSES ):
243
251
return False , str (obj )
244
252
elif isinstance (obj , datetime .timedelta ):
245
253
return False , str (obj .seconds )
246
- elif attr .has (type (obj )):
247
- result = cls ._markdown_result_complex (obj , level )
248
254
elif hasattr (obj , '_asdict' ):
249
255
result = cls ._markdown_result (obj ._asdict (), level )
250
256
elif hasattr (obj , '__dict__' ) or isinstance (obj , dict ):
0 commit comments