pyo3_stub_gen_derive

Attribute Macro gen_stub_pyfunction

source
#[gen_stub_pyfunction]
Expand description

Embed metadata for Python stub file generation for #[pyfunction] macro

#[pyo3_stub_gen_derive::gen_stub_pyfunction]
#[pyo3::pyfunction]
#[pyo3(name = "is_odd")]
pub fn is_odd(x: u32) -> bool {
    todo!()
}

The function attributed by #[gen_stub_pyfunction] will be appended to default stub file. If you want to append this function to another module, add module attribute.

#[pyo3_stub_gen_derive::gen_stub_pyfunction(module = "my_module.experimental")]
#[pyo3::pyfunction]
#[pyo3(name = "is_odd")]
pub fn is_odd(x: u32) -> bool {
    todo!()
}