Registry / type-stubs / pygobject-stubs

pygobject-stubs

JSON →
library2.17.0pypypiunverified

Typing stubs for PyGObject, providing type hints for GLib, GObject, Gtk, Gdk, Gio, and other GNOME libraries. Version 2.17.0 supports Python >=3.10. This package enables static type checking (mypy, pyright) for PyGObject code and is actively maintained alongside PyGObject releases. Release cadence is irregular, tied to GNOME releases and bug fixes.

pip install pygobject-stubs
INSTALL
IMPORT
SIG · PYGOBJECT-STUBS
P
pygobject-stubs
type-stubspythonv2.17.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✕ build_error
✕ build_error
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
1/2 runs
1/2 runs
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Gtk.Window
from gi.repository import Gtk; win = Gtk.Window()
from gi import Gtk; win = Gtk.Window()
The 'gi.repository' submodule is required for correct stubs resolution.
GLib.MainLoop
from gi.repository import GLib; loop = GLib.MainLoop()
import GLib; loop = GLib.MainLoop()
GLib is part of the gi.repository namespace, not a top-level module.

Quickstart example showing correct import pattern and basic usage for type-checking.

from gi.repository import Gtk, Gio # Attempt to get the default display (succeeds only if running under X11/Wayland) display = Gdk.Display.get_default() if display is None: raise RuntimeError('No display available: ensure DISPLAY or WAYLAND_DISPLAY is set') # Example: create a simple window (won't show without main loop; just for type-checking) win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL) win.set_default_size(200, 200) win.show_all() # Type-check with mypy: mypy --enable-incomplete-feature=GenericParenTypeHints script.py
Debug
Known issues
gotchaStubs are NOT complete: many functions have missing or overly generic type hints. Use `Any` or `# type: ignore` for uncovered APIs.
fix
Run mypy with --strict only if you accept suppressing many errors, or use --warn-unused-ignores to track where stubs are missing.
affects: all
gotchaInstall order matters: pygobject-stubs must be installed AFTER PyGObject to ensure correct bytecode compilation. Otherwise, stubs may not be recognized.
fix
Install PyGObject first: pip install PyGObject && pip install pygobject-stubs
affects: all
deprecatedStubs for GTK3 vs GTK4 are separate; pygobject-stubs covers GTK3. For GTK4, use gtk4-stubs (not included).
fix
If targetting GTK4, install gtk4-stubs and use from gi.repository import Gtk4 (if available)
affects: all
gotchamypy version incompatibility: old mypy (<0.990) may fail to find stubs. Ensure mypy >=1.0 for best results.
fix
Upgrade mypy: pip install 'mypy>=1.0'
affects: <=2.17.0
Upgrade
Version history
2.17.0latest on PyPI · released Mar 20, 2026
Audit
Dependencies
PyGObjectoptionalStubs annotate PyGObject's C extensions; runtime typing not needed but required for correct usage.
mypyoptionalCommonly used for type-checking with these stubs.
Agent activity
33 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
pygobject-stubs — pip install pygobject-stubs · libregistry