Skip to content

Functions not being included in generated type stubs #5033

@abrisco

Description

@abrisco

Bug Description

From #3977

the only introspection data created is the list of function

If I understand this correctly it would mean functions are expected to be added to generated stubs but upon running it myself I don't see any function data being included.

When I try generating stubs for @rules_pyo3//pyo3/private/tests/string_sum/string_sum.rs:

use pyo3::prelude::*;

#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
    Ok((a + b).to_string())
}

#[pymodule]
fn string_sum(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
    Ok(())
}

the only stubs available are __init__.py (which I expect) but they're empty.

{
    "__init__.pyi": "",
}

Steps to Reproduce

  1. Clone https://github.com/abrisco/rules_pyo3/tree/stubgen
  2. Run bazel build //pyo3/private/tests/string_sum:string_sum

Backtrace

Your operating system and version

Linux, MacOS, Windows

Your Python version (python --version)

Python 3.11.11

Your Rust version (rustc --version)

1.85.1 (4eb161250 2025-03-15)

Your PyO3 version

0.25.0-dev

How did you install python? Did you use a virtualenv?

N/A

Additional Info

I know my steps to repro are Bazel but I can work with someone to get more canonical repro steps. My hope was that I could provide enough info so that the issue might be obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions