Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyo3 experimental-inspect instead of generate_stubs.py #829

Open
haixuanTao opened this issue Mar 9, 2025 · 4 comments
Open

Use pyo3 experimental-inspect instead of generate_stubs.py #829

haixuanTao opened this issue Mar 9, 2025 · 4 comments
Labels
good first issue Good for newcomers python Python API

Comments

@haixuanTao
Copy link
Collaborator

Currently dora use a custom script called generate_stubs.py to generate type hinting in python.

Unfortunately, this typing is not perfect as it requires manual type hinting and has many depreciated feature when linted with:

uvx ruff check --select UP

We can try to run pyo3 with the feature flag experimental-inspect and see if this can be a good automatic stub generator.

To do this, we just need to replace in Cargo.toml:

pyo3 = { version = "0.23", features = [
    "eyre",
    "abi3-py37",
    "multiple-pymethods",
] }

with:

pyo3 = { version = "0.23", features = [
    "eyre",
    "abi3-py37",
    "multiple-pymethods",
    "experimental-inspect"
] }
@Ignavar
Copy link
Contributor

Ignavar commented Mar 10, 2025

Hey, I was just working on this issue. Could you clarify how I can check if the issue is resolved after making the changes? That would be really helpful in troubleshooting.

@haixuanTao
Copy link
Collaborator Author

haixuanTao commented Mar 10, 2025

So, basically, if this functionality work, you should be able to see type information as well as documentation within python inspection: https://stackoverflow.com/questions/37288135/inspect-module-for-python that is not based on our current __init__.pyi . You can delete the __init__.pyi reinstall using maturin develop to see if you see any difference.

@Ignavar
Copy link
Contributor

Ignavar commented Mar 12, 2025

I believe it's still not working. I made the necessary changes and followed the steps you provided, but I’m still encountering an error when inspecting it.
Image

@haixuanTao
Copy link
Collaborator Author

OK thanks for trying :S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers python Python API
Projects
None yet
Development

No branches or pull requests

2 participants