Open laoshaw opened 3 months ago
Is your vim using a LSP or something that is actually aware of typestubs? If it's analyzing "real" code only it won't find it.
yes I'm using coc-nvim that has coc-pyright installed, it worked fine with other python packages, it can also autocomplete GLib and Gtk methods etc, but the warning (see the screenshot) always stays no matter what I try, not a showstopper though.
I'm having the same problem. I'm using the Pylance extension from VsCode, which uses pyright under the hood.
The typestubs are normal PEP 561 typestubs.
If your editor or type checker does not find them then they are most likely not installed or something is not configured correctly on your end. Did you make sure to read the README and specifiy the config-settings to tell what stubs to generate?
You can try uninstalling the typestubs and reinstalling them, with the config-settings. Make sure to pass --no-cache-dir
like explained in the README.
But if you do not specify config-settings, there are still default versions used. So it should still work. Still, confirm that the typestubs are actually installed.
After this, check if the typestubs are recognized by pyright itself (without VS Code).
As @lashawn said, the stubs work fine. The only problem is the warning. That's all. Perhaps the problem is on the pyright side.
But if the imports are not resolved then how can the stubs work? Are you sure the warning isn't coming from VSCode itself?
are you maybe using virtual environments? or conda environments? if yes you need to install the stubs in these environments.
if your stubs work otherwise, maybe open a issue on the pylance or pyright tracker and ask what the problem could be.
other things to check that come to mind
gi
installedgi
or the stubs installed with the -e
(editable) switchSide Note: gi.require_version() must come before the import, as it makes sure that version 4.0 is imported. Afterwards it does nothing.
Yes, i use venv. Here's my setup: I use rye for project management.
I solved this issue by adding following rule to pyproject.toml
, corresponding to pyright documentation.
[tool.pyright]
reportMissingModuleSource = false
After I did: pip install pygobject-stubs --no-cache-dir --config-settings=config=Gtk4,Gdk4,Soup3 (for gtk4), or just the default install(pip install pygobject-stubs pygobject), my vim still reports above warning, it runs, but the warning stays no matter what.