Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich._inspect Namespace Reference

Data Structures

class  Inspect
 

Functions

str _first_paragraph (str doc)
 
Tuple[type,...] get_object_types_mro (Union[object, Type[Any]] obj)
 
Collection[str] get_object_types_mro_as_strings (object obj)
 
bool is_object_one_of_types (object obj, Collection[str] fully_qualified_types_names)
 

Function Documentation

◆ _first_paragraph()

str _first_paragraph ( str  doc)
protected
Get the first paragraph from a docstring.

Definition at line 17 of file _inspect.py.

17def _first_paragraph(doc: str) -> str:
18 """Get the first paragraph from a docstring."""
19 paragraph, _, _ = doc.partition("\n\n")
20 return paragraph
21
22
for i

References i.

Referenced by Inspect._get_formatted_doc().

Here is the caller graph for this function:

◆ get_object_types_mro()

Tuple[type, ...] get_object_types_mro ( Union[object, Type[Any]]  obj)
Returns the MRO of an object's class, or of the object itself if it's a class.

Definition at line 238 of file _inspect.py.

238def get_object_types_mro(obj: Union[object, Type[Any]]) -> Tuple[type, ...]:
239 """Returns the MRO of an object's class, or of the object itself if it's a class."""
240 if not hasattr(obj, "__mro__"):
241 # N.B. we cannot use `if type(obj) is type` here because it doesn't work with
242 # some types of classes, such as the ones that use abc.ABCMeta.
243 obj = type(obj)
244 return getattr(obj, "__mro__", ())
245
246

References i.

Referenced by pip._vendor.rich._inspect.get_object_types_mro_as_strings().

Here is the caller graph for this function:

◆ get_object_types_mro_as_strings()

Collection[str] get_object_types_mro_as_strings ( object  obj)
Returns the MRO of an object's class as full qualified names, or of the object itself if it's a class.

Examples:
    `object_types_mro_as_strings(JSONDecoder)` will return `['json.decoder.JSONDecoder', 'builtins.object']`

Definition at line 247 of file _inspect.py.

247def get_object_types_mro_as_strings(obj: object) -> Collection[str]:
248 """
249 Returns the MRO of an object's class as full qualified names, or of the object itself if it's a class.
250
251 Examples:
252 `object_types_mro_as_strings(JSONDecoder)` will return `['json.decoder.JSONDecoder', 'builtins.object']`
253 """
254 return [
255 f'{getattr(type_, "__module__", "")}.{getattr(type_, "__qualname__", "")}'
256 for type_ in get_object_types_mro(obj)
257 ]
258
259

References pip._vendor.rich._inspect.get_object_types_mro().

Referenced by pip._vendor.rich._inspect.is_object_one_of_types().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_object_one_of_types()

bool is_object_one_of_types ( object  obj,
Collection[str]   fully_qualified_types_names 
)
Returns `True` if the given object's class (or the object itself, if it's a class) has one of the
fully qualified names in its MRO.

Definition at line 260 of file _inspect.py.

262) -> bool:
263 """
264 Returns `True` if the given object's class (or the object itself, if it's a class) has one of the
265 fully qualified names in its MRO.
266 """
267 for type_name in get_object_types_mro_as_strings(obj):
268 if type_name in fully_qualified_types_names:
269 return True
270 return False

References pip._vendor.rich._inspect.get_object_types_mro_as_strings().

Here is the call graph for this function: