Skip to content

Conversation

@g-bauer
Copy link
Contributor

@g-bauer g-bauer commented Nov 18, 2025

Work in progress of automatic stub file generation using experimental-inspect and pyo3-introspection. See the documentation and the related issue.

Currently missing

  • Proper support for enum variants. Currently doesn't show variants for autocompletion.
  • Docstrings are currently not added to stubs. They seem to work in jupyter and marimo due to dynamically loading the docstrings.
  • SIObject (PyObjects defined in other crates) - can be managed via custom signature
  • Return types - can be managed via custom signature as well.

How to use this

Inside feos/py-feos:

  1. Generate cdylib via maturin
  2. Run cargo run --bin stub_gen. You might need to adjust the path. We could add a command line argument for this.
  3. The above command generates feos.pyi.
  4. Run maturin again. It will now include the stub file. (Look for 📖 Found type stub file at feos.pyi)

GH Action

  • Add stub generation step for wheel-test action. Load stub file in publishing action.
  • In the future, this might be a feature of maturin

Todo

  • Check if stubs can be used with mkdocs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants