pygobject-stubs icon indicating copy to clipboard operation
pygobject-stubs copied to clipboard

`Gtk.NoSelection.__init__` incorrectly typed

Open demberto opened this issue 1 year ago • 4 comments

Gtk.NoSelection.__init__

https://github.com/pygobject/pygobject-stubs/blob/master/src/gi-stubs/repository/_Gtk4.pyi#L10709

Actual error

model=Gtk.NoSelection(Gtk.StringList.new(["A", "B", "C"])),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: GObject.__init__() takes exactly 0 arguments (1 given)

Solution

Use Gtk.NoSelection.new (very weird API bindings)

Version info

  • GObject: 3.44.1
  • pygobject-stubs: 2.7.0
  • Gtk: 4.10.3

demberto avatar Apr 17 '23 21:04 demberto

I think the introspection is wrong here for some reason but i cant find the error in https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtknoselection.c#L273 and idea @mat-xc

lovetox avatar May 09 '23 17:05 lovetox

I am not sure I am following. It's correct for __init__ to take 0 arguments. It only allows kwargs arguments.

matperc avatar May 09 '23 17:05 matperc

ah ok so is this true for all inits in GTK4? Is this something PyGObject enforces ? this means we could specifiy this making the init

def init(self, * , model: Gio.ListModel = ... )

lovetox avatar May 09 '23 17:05 lovetox

We already discussed it here.

I am on mobile right now, if your solution works I thinks it is a good idea

matperc avatar May 09 '23 17:05 matperc