pygobject-stubs
pygobject-stubs copied to clipboard
Support GLib.option (or use a better placeholder)
Here is a simple example:
from gi.repository import GLib
parser = GLib.option.OptionParser(option_list=[
GLib.option.make_option('--flag', action='store_true', help='flag'),
])
parser.parse_args()
print('flag is', parser.values.flag)
mypy complains about type errors:
$ mypy repr.py
repr.py:3: error: "ellipsis" has no attribute "OptionParser" [attr-defined]
repr.py:4: error: "ellipsis" has no attribute "make_option" [attr-defined]
Found 2 errors in 1 file (checked 1 source file)
It looks like the placeholder for this attribute is currently a literal ellipsis: https://github.com/pygobject/pygobject-stubs/blob/97a1be6bdd843d1eb0bfe617e3f8e635592335e2/src/gi-stubs/repository/GLib.pyi#L206
I believe stubgen annotates attributes with _typeshed.Incomplete
when the type cannot be determined. typing.Any
would probably work as well.
When was this added? I find no documentation online for this.
Seems its this module here https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/gi/_option.py