pygobject / pygobject-stubs

PEP 561 Typing Stubs for PyGObject
GNU Lesser General Public License v2.1
74 stars 26 forks source link

The Gdk[3].RGBA constructor's arguments are out of order #186

Closed ferdnyc closed 6 months ago

ferdnyc commented 6 months ago

In the _Gdk3 stubs for Gdk.RGBA, it claims the constructor's signature is: __init__(self, blue, green, red, alpha). Pretty sure it's not! (It's kind of right there in the name, "R-G-B-A".)

https://github.com/pygobject/pygobject-stubs/blob/15a36244c0684e176384a4dd15ff25a3ebf8cf12/src/gi-stubs/repository/_Gdk3.pyi#L3295-L3307

It almost looks like the colors were just blindly alphabetized, or something. (Though that wouldn't explain how alpha stayed at the end.)

ferdnyc commented 6 months ago

Heh. Seems when the .pyi file was originally imported, the class members were alphabetized:

https://github.com/pygobject/pygobject-stubs/blob/647c841f9f05696ca5350a715476da76eb3ef2f7/src/gi-stubs/__multi_version_stubs/Gdk3.pyi#L3033-L3045

That got sorted out somewhere along the way, but the crazy constructor ordering stuck around.

ferdnyc commented 6 months ago

Pretty sure it's not!

Actually, now I'm definitely sure it's not, as here's the relevant contents of gi/overrides/Gdk.py:

if GDK3:
    # Introduced since Gtk-3.0
    class RGBA(Gdk.RGBA):
        def __init__(self, red=1.0, green=1.0, blue=1.0, alpha=1.0):
            Gdk.RGBA.__init__(self)
            self.red = red
            self.green = green
            self.blue = blue
            self.alpha = alpha