caikit.core.signature_parsing.docstrings ======================================== .. py:module:: caikit.core.signature_parsing.docstrings .. autoapi-nested-parse:: This package handles all the gorp of finding types from docstrings given our custom conventions Attributes ---------- .. autoapisummary:: caikit.core.signature_parsing.docstrings.log Functions --------- .. autoapisummary:: caikit.core.signature_parsing.docstrings.get_return_type caikit.core.signature_parsing.docstrings.is_optional caikit.core.signature_parsing.docstrings.get_arg_type caikit.core.signature_parsing.docstrings._get_candidate_type_names_from_docstring caikit.core.signature_parsing.docstrings._get_docstring_type caikit.core.signature_parsing.docstrings._extract_nested_type caikit.core.signature_parsing.docstrings._extract_type_from_pymodule Module Contents --------------- .. py:data:: log .. py:function:: get_return_type(fn: Callable) -> Optional[Type] Grabs the return type off the docstring, if possible Args: fn: The function to get the return value of e.g. my_caikit_library.modules.classification.Transformer.run Returns: The return type of `fn`, if it can be parsed from the docstring. Otherwise, None .. py:function:: is_optional(fn: Callable, arg_name: str) -> bool Checks if the `arg_name` param from `fn`s docstring is optional by checking if param description starts with "an optional" or "optional". Args: fn: The function to get the type of a parameter from e.g. my_caikit_library.modules.classification.Transformer.run arg_name: The name of the parameter that we should try to get the type of e.g. "raw_document" .. py:function:: get_arg_type(fn: Callable, arg_name: str) -> Optional[Type] Grabs the type of the `arg_name` param from `fn`s docstring, if possible Args: fn: The function to get the type of a parameter from e.g. my_caikit_library.modules.classification.Transformer.run arg_name: The name of the parameter that we should try to get the type of e.g. "raw_document" Returns: The return type of `fn`, if it can be parsed from the docstring. Otherwise, None .. py:function:: _get_candidate_type_names_from_docstring(param: Optional[docstring_parser.common.DocstringParam]) -> Tuple[List[str], List[str]] .. py:function:: _get_docstring_type(candidate_type_names: List[str]) -> Optional[Type] Given a parsed docstring parameter, look in all of the possible places for the actual type .. py:function:: _extract_nested_type(type_name: str) -> Optional[Type] .. py:function:: _extract_type_from_pymodule(py_module: Union[Type, Dict], type_name: str) -> Optional[Type] This walks down a type hierarchy to try to find the concrete type given an input string name Args: py_module (Type | Dict): A python module, or dictionary of modules, to start walking to find "type_name" type_name (str): The name of the type that we're trying to find. e.g. "caikit.core.data_model.ProducerId" Returns: Optional[Type]: The type of "type_name", or None if it cannot be found