-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Python submodule to support IDE type hints #304
Comments
Hi @ChristopherRabotin , I'd like to give it a try. If it's convenient, please assign it to me. |
With pleasure! I briefly tried the script from the |
@cardigan1008 , there's a new crate that aims to make this straight forward: PyO3/pyo3#2454 (comment) . I have not tried it, but it looks quite promising! |
Sounds great! Thanks for reminding. I’ll definitely give it a try soon. |
Apologize for the delay in updating. I've just completed my project and have had the opportunity to try using pyo3-stub-gen. It turns out that some classes, such as LatestLeapSeconds, LeapSecondsFile, Ut1Provider, PyHifitimeError, PyDurationError, and PyParsingError, work well. However, there are some classes that don’t work as expected, primarily because pyo3-stub-gen fails to parse Duration into its own stub type. The pyi file generated by pyo3-stub-gen can be found here. |
Hi there! No problem, this isn't a major rush. Good to know that it works in some cases but not others. Does the stub generator print an error when it fails by any chance? Thanks |
Yes, when I tried to implement it for Duration. The error goes like this: error[E0433]: failed to resolve: could not find `any` in `std`
--> src/duration/mod.rs:69:32
|
69 | #[cfg_attr(feature = "python", gen_stub_pyclass)]
| ^^^^^^^^^^^^^^^^
| |
| could not find `any` in `std`
| in this procedural macro expansion
|
::: /home/yunboni/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-stub-gen-derive-0.6.0/src/lib.rs:22:1
|
22 | pub fn gen_stub_pyclass(_attr: TokenStream, item: TokenStream) -> TokenStream {
| ----------------------------------------------------------------------------- in this expansion of `#[gen_stub_pyclass]`
|
help: consider importing this struct
|
11 + use std::any::TypeId;
| |
Hi there, Have you tried the recommended import that's shown in the compilation error? Also, would it be possible for you to set up a PR with the changes the add the `gen_stub_pyclass? That way we can ensure that the type hints are built in the CI every time. Thanks |
I’ve tried the recommended import, but unfortunately, it still failed. It seems that the tool itself has some issues, and I’ve already proposed several issues regarding it. I’ll submit the PR to add the gen_stub_pyclass as soon as possible. However, please note that the PR may not cover all features. |
IDEs don't know what's in the Python module. This can be solved by writing
pyi
files.The goal of this task is to essentially repeat what Dora did here: dora-rs/dora#493 .
The text was updated successfully, but these errors were encountered: