MCPcopy
hub / github.com/Textualize/rich / _safe_isinstance

Function _safe_isinstance

rich/pretty.py:161–168  ·  view source on GitHub ↗

isinstance can fail in rare cases, for example types with no __class__

(
    obj: object, class_or_tuple: Union[type, Tuple[type, ...]]
)

Source from the content-addressed store, hash-verified

159
160
161def _safe_isinstance(
162 obj: object, class_or_tuple: Union[type, Tuple[type, ...]]
163) -> bool:
164 """isinstance can fail in rare cases, for example types with no __class__"""
165 try:
166 return isinstance(obj, class_or_tuple)
167 except Exception:
168 return False
169
170
171def install(

Callers 7

_ipy_display_hookFunction · 0.85
display_hookFunction · 0.85
is_expandableFunction · 0.85
to_reprFunction · 0.85
iter_rich_argsFunction · 0.85
_traverseFunction · 0.85
pretty_reprFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected