Skip to content

Stub file information doesn't seem to be included from _lib.pyi #791

Description

@jonasdedden

Package setup

We have some internal namespace package written in Rust & PyO3.

It's organized like this:

pyproject.toml
uv.lock
tests/
  [...]
src/
  [internal namespace]/
    [pkg name]/
      __init__.py
      py.typed
      _lib.so
      _lib.pyi

_lib.so is the shared library built from our Rust code. In our __init__.py, we reference this:

$ cat __init__.py
from ._lib import [ClassA, ClassB, ...]

__all__ = [
    "[ClassA]",
    "[ClassB]",
    ...
]

Problem description

When I now create documentation by calling pdoc [namespace].[pkgname], I'm given this function documentation for example:

Image

(ignore the slightly broken formatting of the docstring, this is because we haven't standardized docstring formats yet 😅 )

As you can see, it contains function signature defaults, all parameters and the docstring. But it entirely misses typing information that is in _lib.pyi.

When I create documentation with pdoc [namespace].[pkgname]._lib, I do see information from the stub file though!

Image

But now, the documentation is limited purely to the _lib submodule. Is there a way to create documentation of the entire package, but also correctly discovering stub files automatically?

System Information

$ pdoc --version
pdoc: 15.0.1
Python: 3.11.9
Platform: Linux-6.13.7-1-MANJARO-x86_64-with-glibc2.41

Activity

  1. mhils commented on Apr 9, 2025

    @mhils
    Member

    One workaround here is to put your type annotations into __init__.pyi.

  2. inventshah commented on Nov 11, 2025

    @inventshah

    @mhils is this a use case you are interested in supporting? I've prepared a patch if so.

    My use case is similar to OP but with nanobind bindings instead of PyO3.

  3. mhils commented on Nov 11, 2025

    @mhils
    Member

    If you have a patch please send it, really depends on how much complexity we're adding. :)

  4. inventshah commented on Nov 11, 2025

    @inventshah

    Opened a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions