Skip to main content

maybe_update_state

Updates the global state object with application, function, and module or file path information extracted from the Click context parameters. It validates that the provided path exists or matches a valid Python module pattern, exiting the process with an error message if the input is invalid.

def maybe_update_state(
ctx: click.Context
) - > None

Updates the global state object with application, function, and source details extracted from the Click context. This function ensures that the provided source is either a valid existing file path or a syntactically correct Python module name before updating the state.

Parameters

NameTypeDescription
ctxclick.ContextThe Click context object containing parsed command-line parameters such as 'path_or_module', 'app', and 'func'.

Returns

TypeDescription
NoneNothing is returned; the function modifies the global state object directly.