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

Function inspect

rich/__init__.py:120–173  ·  view source on GitHub ↗

Inspect any Python object. * inspect(<OBJECT>) to see summarized info. * inspect(<OBJECT>, methods=True) to see methods. * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help. * inspect(<OBJECT>, private=True) to see private attributes (single underscore). * inspect(

(
    obj: Any,
    *,
    console: Optional["Console"] = None,
    title: Optional[str] = None,
    help: bool = False,
    methods: bool = False,
    docs: bool = True,
    private: bool = False,
    dunder: bool = False,
    sort: bool = True,
    all: bool = False,
    value: bool = True,
)

Source from the content-addressed store, hash-verified

118
119
120def inspect(
121 obj: Any,
122 *,
123 console: Optional["Console"] = None,
124 title: Optional[str] = None,
125 help: bool = False,
126 methods: bool = False,
127 docs: bool = True,
128 private: bool = False,
129 dunder: bool = False,
130 sort: bool = True,
131 all: bool = False,
132 value: bool = True,
133) -> None:
134 """Inspect any Python object.
135
136 * inspect(<OBJECT>) to see summarized info.
137 * inspect(<OBJECT>, methods=True) to see methods.
138 * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
139 * inspect(<OBJECT>, private=True) to see private attributes (single underscore).
140 * inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
141 * inspect(<OBJECT>, all=True) to see all attributes.
142
143 Args:
144 obj (Any): An object to inspect.
145 title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
146 help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
147 methods (bool, optional): Enable inspection of callables. Defaults to False.
148 docs (bool, optional): Also render doc strings. Defaults to True.
149 private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
150 dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
151 sort (bool, optional): Sort attributes alphabetically, callables at the top, leading and trailing underscores ignored. Defaults to True.
152 all (bool, optional): Show all attributes. Defaults to False.
153 value (bool, optional): Pretty print value. Defaults to True.
154 """
155 _console = console or get_console()
156 from rich._inspect import Inspect
157
158 # Special case for inspect(inspect)
159 is_inspect = obj is inspect
160
161 _inspect = Inspect(
162 obj,
163 title=title,
164 help=is_inspect or help,
165 methods=is_inspect or methods,
166 docs=is_inspect or docs,
167 private=private,
168 dunder=dunder,
169 sort=sort,
170 all=all,
171 value=value,
172 )
173 _console.print(_inspect)
174
175
176if __name__ == "__main__": # pragma: no cover

Callers 5

renderFunction · 0.90
test_renderFunction · 0.90
test_qualname_in_slotsFunction · 0.90
reportFunction · 0.90

Calls 3

InspectClass · 0.90
get_consoleFunction · 0.85
printMethod · 0.80

Tested by 4

renderFunction · 0.72
test_renderFunction · 0.72
test_qualname_in_slotsFunction · 0.72