Skip to content
Discussion options

You must be logged in to vote

Maturin 1.15.0 bundles pyo3-introspection 0.29.0, independently of the PyO3 version in your crate. The missing submodule re-export was fixed in PyO3 #6360; Maturin's main branch already has the generator update.

For 1.15.0, you can keep your module layout. Qualify the return annotation:

#[pyo3(signature = () -> "defs.MyClass")]

Then, after generating, add this to src/mypackage/_native/__init__.pyi:

from . import defs as defs

That binds _native.defs and lets the return annotation resolve to its MyClass. Regenerating the stubs will overwrite the manual import.

Checked a minimal stub fixture with mypy 2.4.0 and Pyright 1.1.414 using Codex. Both reject the missing binding and accept this layo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lonami
Comment options

Answer selected by Lonami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants