-
Notifications
You must be signed in to change notification settings - Fork 769
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
Stubs not found for installed typed library #3084
Comments
I've installed the latest version of the gi-docgen (version I recommend contacting the maintainer of this library and suggesting that they include a "py.typed" file marker. |
Thanks, I'm going to send them a PR then 😊 However, I've two considerations for discussion.
|
This isn't an error by default. You will see this error only if you enable the When you use the stub creation mechanism, pyright (the type checker that underlies pylance) creates a "first draft" set of type stubs. You will typically need to make improvements to them manually. For more information about type stubs, refer to this documentation. Ideally type information is maintained by the library author and distributed with the library. That is increasingly common, although we're finding that many libraries that claim to contain type information (i.e. include a "py.typed" file) are incomplete in terms of typing. The command-line version of pyright includes a "--verifytypes" mode that library authors can use to identify missing type information within their library. For more details, refer to this documentation. |
Thank you very much for your thorough explanation! 😊 About the stub generation, yes, I was expecting it not to be necessarily complete indeed. What I found surprising was that many of the automatically inferred properties were lost in the process. Perhaps the code that generates the stubs and the one that suggests the props in the UI are using different inference rules? 🤔 |
The stub generator does not emit inferred return types for functions or methods. Inferred types can be inaccurate, and our philosophy is that it's better to omit a return type annotation than to include an inaccurate one. By omitting a return type annotation, the developer can easily determine which types are missing and add them as needed. The stub generator does include a comment with the inferred type, so if you agree with the inferred type, you can simply uncomment it. |
Oh, I see now, makes sense. Again, thanks a lot for your explanations, I really appreciate that! 😊 |
Possibly related to:
Environment data
Code Snippet
Repro Steps
.vscode .vscode/settings.json
venv.sh
Install and setup with
source venv.sh
Expected behavior
Stubs to be found and function correctly.
Actual behavior
PyLance reports not finding stubs, yet everything seems to be found correctly.
If I follow the advice to create stubs, a typings directory is created but then the types are inferred incorrectly.
Note how in the second picture fewer props are found (e.g. missing
includes
,c_includes
).Logs
Too long, uploading as a file: log.txt
The text was updated successfully, but these errors were encountered: