reflection¶
Reflection module.
Added in version 1.1.
- oslo_utils.reflection.accepts_kwargs(function: Any) bool¶
Returns
Trueif function accepts kwargs otherwiseFalse.
- oslo_utils.reflection.get_all_class_names(obj: ~typing.Any, up_to: type = <class 'object'>, fully_qualified: bool = True, truncate_builtins: bool = True) Generator[str, None, None]¶
Get class names of object parent classes.
Iterate over all class names object is instance or subclass of, in order of method resolution (mro). If up_to parameter is provided, only name of classes that are sublcasses to that class are returned.
- oslo_utils.reflection.get_callable_args(function: Any, required_only: bool = False) list[str]¶
Get names of callable arguments.
Special arguments (like
*argsand**kwargs) are not included into output.If required_only is True, optional arguments (with default values) are not included into output.
- oslo_utils.reflection.get_callable_name(function: Any) str¶
Generate a name from callable.
Tries to do the best to guess fully qualified callable name.
- oslo_utils.reflection.get_class_name(obj: Any, fully_qualified: bool = True, truncate_builtins: bool = True) str¶
Get class name for object.
If object is a type, returns name of the type. If object is a bound method or a class method, returns its
selfobject’s class name. If object is an instance of class, returns instance’s class name. Else, name of the type of the object is returned. If fully_qualified is True, returns fully qualified name of the type. For builtin types, just name is returned. TypeError is raised if can’t get class name from object.
- oslo_utils.reflection.get_member_names(obj: Any, exclude_hidden: bool = True) list[str]¶
Get all the member names for a object.
- oslo_utils.reflection.get_members(obj: Any, exclude_hidden: bool = True) Generator[tuple[str, Any], None, None]¶
Yields the members of an object, filtering by hidden/not hidden.
Added in version 2.3.
- oslo_utils.reflection.get_method_self(method: Any) Any¶
Gets the
selfobject attached to this method (or none).
- oslo_utils.reflection.is_bound_method(method: Any) bool¶
Returns if the given method is bound to an object.
- oslo_utils.reflection.is_same_callback(callback1: Any, callback2: Any) bool¶
Returns if the two callbacks are the same.
- oslo_utils.reflection.is_subclass(obj: Any, cls: type) bool¶
Returns if the object is class and it is subclass of a given class.