-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add type stubs for python code #34
Conversation
Hi, thank you for adding this, I meant to do it for a long time! For example, I removed the docstrings from the stubs file, I modified them in the rust file to make sure that I am seeing the correct ones, and after rebuilding the package I am getting this: |
They do not appear for me in VSCode using Pylance. I tried removing some docstrings from the In the wheel, the docstrings generated from maturin are (probably) inside the binary |
Is this a VSCode extension? I'm not finding it, perhaps because I am using VSCodium?
I added To be complete about the steps that make it work for me:
|
Ok, I tried changing the language server from Pylance to Jedi (the other one that is included in the VSCode Python extension, and that is also used by pylsp) and now it detects the docstrings from "rust". I think the difference lies in that Jedi gets the docstrings from runtime (running |
How painful is using Jedi instead of Pylance? My concern about duplicating the docstrings is that they could get out of sync, so I would tend to avoid it if possible, but if we can easily autogenerate this file including docstrings, that could be an option. |
Yes, I didn't like this solution either for that reason. They seem to be working on generating them automatically: PyO3/pyo3#2454 Regarding the Jedi vs Pylance, I think the ecosystem is shifting towards the Pylance approach of not running Python code for the language server. I believe the ruff language server will do the same if it starts providing autocomplete features (they are currently working on adding a static type checker). |
Ok, then let's merge this now because it is a clear improvement and so that I can look at your other PRs, and I will create an issue to keep this in mind. Thank you! |
Hi, thanks for this package.
I added type stubs based on https://pyo3.rs/v0.23.3/python-typing-hints,
that provides autocomplete and type checking in VS Code.
There are other changes that I made on top of this branch, updating the type hints.