-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Generate type stub files for python API #41264
Comments
So if anything this is a packaging issue, but we'd need to know what platform you're using and more details about how you installed qgis and are using the bindings. |
I looked into this further. For some reason, the stub files don't get copied across to the installation directory in the qgis container image. I'm using stubgen -p qgis -o stubs
cp /QGIS/build/output/python/qgis/*.pyi stubs/qgis Unfortunately, I found that there are some manual fixes required to get mypy to work because of the following error: MYPYPATH=/stubs mypy some_plugin_file.py
/stubs/qgis/_core.pyi:112: error: cannot assign to None
Found 1 error in 1 file (errors prevented further checking) I think for now, I'll just create a stubs package similar to PyQt5-stubs with these fixes applied. |
The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". |
At least the stub files are not packaged in when installing using the new osgeo4w installer. Apparently no other than *.pyd files are copied by cmake when building on Windows if I can interpret https://github.com/qgis/QGIS/blob/master/cmake/SIPMacros.cmake#L170 correctly. Unfortunately I don't yet have enough competence on cmake to make a PR. |
This would be helpful also for pylance in visual code studio. That way people could use installed QGIS Python folder for auto completion. They are created during the build, but they don't seem to be packages or copied during installation. @jef-n is this something we could include in installation? The files are not too heavy. |
@jef-n Thanks! Much appreciated. |
Hi @jef-n where can I find these .pyi files? I can't seem to find them either in Windows or Linux installations. |
Feature description.
It'd be useful to be able to use mypy to type check QGIS plugins. The QGIS api bindings don't currently include stub files (
.pyi
files) so the type checking is rather limited.Additional context
It seems like sip is able to generate stub files as part of the build. This is used to generate stubs for PyQt5.
The text was updated successfully, but these errors were encountered: