Skip to content
Advertisement

code completion support with gi.repository in VS Code

I’m trying do code a simple app with GTK4 in Python using VS Code.

What I do:

gi.require_version("Gtk", "4.0")
from gi.repository import Gtk

I don’t have any auto completion or type hints in my IDE because gi.repository uses dynamic imports, is there any way to change this behavior?

Advertisement

Answer

In Python typing annotations can be written separately from the main module code (in .pyi files or as a stubs module).

Run $ pip install PyGObject-stubs to install 3d-party type annotations and reload VS Code window

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement