Skip to content

yival.dataset.data_utils

read_code_from_path_or_module

def read_code_from_path_or_module(path_or_module: str) -> Optional[str]

Reads the source code either from an absolute file path or from a module, refined version.

Arguments:

  • path_or_module (str): Either an absolute path to a Python file or a module name followed by a function name.

Returns:

  • Optional[str]: The source code if found, otherwise None.