Installing Stubs
“Stubs” are Python files that don’t include code or logic, instead they include type definintions.
They commonly are used for libraries with logic that are dispatched and defined during runtime (like GTK for example, it is written in C and so the logic does not live in Python) to give linters and type checkers the ability of knowing what is going to run and what is going to be defined ahead of the runtime.
Obtaining a stubs package will enhance code auto-completion and provide type annotations in your editor. To enable these features, you’ll need to install one of the following packages, each of which has its own installation guide.
Fabric Stubs / KataGIR
Section titled “Fabric Stubs / KataGIR”Fabric CLI provides an easy to use, smart and fast stubs generation suite called KataGIR, it is built into the CLI so you can use it right away once you install it (through fabric-cli stubs.)
PyGObject-Stubs
Section titled “PyGObject-Stubs”PyGObject provides a Python package that gives you an advanced auto-completions experience. Yet. It’s not perfect - not all gi repositories are type-annotated or docstringed. This works if you’re planning to stick to online documentation of GTK and Fabric.
GenGIR
Section titled “GenGIR”GenGIR generates a stubs package and installs it for you, whether for global Python packages or a virtual environment.
FakeGIR
Section titled “FakeGIR”FakeGIR is a Python script that generates an overrides file for your editor to use; it’s not considered a real stubs package because you will have to configure your editor to use the overrides file instead of the hints from the code.