Module parse_python

Module parse_python 

Source
Expand description

Parse Python stub syntax and generate PyFunctionInfo and MethodInfo

This module provides functionality to parse Python stub syntax (type hints) and convert them into Rust metadata structures for stub generation.

Re-exportsΒ§

pub use pyfunction::parse_gen_function_from_python_input;
pub use pyfunction::parse_python_function_stub;
pub use pyfunction::parse_python_overload_stubs;
pub use pyfunction::GenFunctionFromPythonInput;
pub use pymethods::parse_python_methods_stub;

ModulesΒ§

pyfunction πŸ”’
Parse Python function stub syntax and generate PyFunctionInfo
pymethods πŸ”’
Parse Python class method stub syntax and generate MethodInfo

FunctionsΒ§

build_parameters_from_ast πŸ”’
Build Parameters directly from Python AST Arguments
dedent πŸ”’
Remove common leading whitespace from all lines (similar to Python’s textwrap.dedent)
escape_python_string πŸ”’
Escape a string for Python syntax
expr_to_type_string πŸ”’
Convert Python expression to type string
expr_to_type_string_inner πŸ”’
Convert Python expression to type string with context
extract_deprecated_from_decorators πŸ”’
Extract deprecated decorator information if present
extract_docstring πŸ”’
Extract docstring from function definition
extract_return_type πŸ”’
Extract return type from function definition
extract_rust_type_marker πŸ”’
Extract type name from pyo3_stub_gen.RustType[β€œTypeName”]
has_overload_decorator πŸ”’
Check if decorator list contains @overload decorator
python_ast_to_python_string πŸ”’
Convert Python AST expression to Python syntax string
type_annotation_to_type_override πŸ”’
Convert Python type annotation to TypeOrOverride