Skip to content

Commit 26eff58

Browse files
authored
imprv: vfunc and AsyncReadyCallback signatures (#308)
- Split `Gio.AsyncReadyCallback` into two private aliases: `_AsyncReadyCallback` for single user_data and `_AsyncReadyVarArgsCallback` for variadic user_data. Public async functions and methods now use the var-args form, while vfuncs and `simple_async_report_gerror_in_idle` use the single form. - Treat vfuncs on objects/interfaces as methods so they receive `self`, keep their destroy/closure args visible, and emit them as positional-only (trailing `/`) since PyGObject's C marshaller invokes them positionally.
1 parent 104b612 commit 26eff58

22 files changed

Lines changed: 1539 additions & 1331 deletions

src/gi-stubs/repository/Adw.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ class AlertDialog(Dialog):
10431043
self,
10441044
parent: _Gtk4.Widget | None,
10451045
cancellable: Gio.Cancellable | None,
1046-
callback: Gio.AsyncReadyCallback[AlertDialog, Unpack[_DataTs]] | None,
1046+
callback: Gio._AsyncReadyVarArgsCallback[AlertDialog, Unpack[_DataTs]] | None,
10471047
*user_data: Unpack[_DataTs],
10481048
) -> None: ...
10491049
@overload
@@ -1052,10 +1052,10 @@ class AlertDialog(Dialog):
10521052
parent: _Gtk4.Widget | None = None,
10531053
cancellable: Gio.Cancellable | None = None,
10541054
*,
1055-
callback: Gio.AsyncReadyCallback[AlertDialog] | None,
1055+
callback: Gio._AsyncReadyVarArgsCallback[AlertDialog] | None,
10561056
) -> None: ...
10571057
def choose_finish(self, result: Gio.AsyncResult) -> str: ...
1058-
def do_response(self, response: str) -> None: ...
1058+
def do_response(self, response: str, /) -> None: ...
10591059
def get_body(self) -> str: ...
10601060
def get_body_use_markup(self) -> bool: ...
10611061
def get_close_response(self) -> str: ...
@@ -5725,18 +5725,18 @@ class MessageDialog(_Gtk4.Window):
57255725
def choose(
57265726
self,
57275727
cancellable: Gio.Cancellable | None,
5728-
callback: Gio.AsyncReadyCallback[MessageDialog, Unpack[_DataTs]] | None,
5728+
callback: Gio._AsyncReadyVarArgsCallback[MessageDialog, Unpack[_DataTs]] | None,
57295729
*user_data: Unpack[_DataTs],
57305730
) -> None: ...
57315731
@overload
57325732
def choose(
57335733
self,
57345734
cancellable: Gio.Cancellable | None = None,
57355735
*,
5736-
callback: Gio.AsyncReadyCallback[MessageDialog] | None,
5736+
callback: Gio._AsyncReadyVarArgsCallback[MessageDialog] | None,
57375737
) -> None: ...
57385738
def choose_finish(self, result: Gio.AsyncResult) -> str: ...
5739-
def do_response(self, response: str) -> None: ...
5739+
def do_response(self, response: str, /) -> None: ...
57405740
def get_body(self) -> str: ...
57415741
def get_body_use_markup(self) -> bool: ...
57425742
def get_close_response(self) -> str: ...

src/gi-stubs/repository/Atk.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ class Hyperlink(GObject.Object, Action):
424424
def parent(self) -> GObject.Object: ...
425425
def do_get_end_index(self) -> int: ...
426426
def do_get_n_anchors(self) -> int: ...
427-
def do_get_object(self, i: int) -> Object: ...
427+
def do_get_object(self, i: int, /) -> Object: ...
428428
def do_get_start_index(self) -> int: ...
429-
def do_get_uri(self, i: int) -> str: ...
429+
def do_get_uri(self, i: int, /) -> str: ...
430430
def do_is_selected_link(self) -> bool: ...
431431
def do_is_valid(self) -> bool: ...
432432
def do_link_activated(self) -> None: ...
@@ -925,11 +925,11 @@ class Object(GObject.Object):
925925
def add_relationship(
926926
self, relationship: _RelationTypeValueType, target: Object
927927
) -> bool: ...
928-
def do_active_descendant_changed(self, child: int | Any | None) -> None: ...
928+
def do_active_descendant_changed(self, child: int | Any | None, /) -> None: ...
929929
def do_children_changed(
930-
self, change_index: int, changed_child: int | Any | None
930+
self, change_index: int, changed_child: int | Any | None, /
931931
) -> None: ...
932-
def do_focus_event(self, focus_in: bool) -> None: ...
932+
def do_focus_event(self, focus_in: bool, /) -> None: ...
933933
def do_get_attributes(self) -> list[int]: ...
934934
def do_get_description(self) -> str: ...
935935
def do_get_index_in_parent(self) -> int: ...
@@ -940,16 +940,16 @@ class Object(GObject.Object):
940940
def do_get_object_locale(self) -> str: ...
941941
def do_get_parent(self) -> Object: ...
942942
def do_get_role(self) -> Role: ...
943-
def do_initialize(self, data: int | Any | None) -> None: ...
944-
def do_property_change(self, values: PropertyValues) -> None: ...
943+
def do_initialize(self, data: int | Any | None, /) -> None: ...
944+
def do_property_change(self, values: PropertyValues, /) -> None: ...
945945
def do_ref_relation_set(self) -> RelationSet: ...
946946
def do_ref_state_set(self) -> StateSet: ...
947-
def do_remove_property_change_handler(self, handler_id: int) -> None: ...
948-
def do_set_description(self, description: str) -> None: ...
949-
def do_set_name(self, name: str) -> None: ...
950-
def do_set_parent(self, parent: Object) -> None: ...
951-
def do_set_role(self, role: _RoleValueType) -> None: ...
952-
def do_state_change(self, name: str, state_set: bool) -> None: ...
947+
def do_remove_property_change_handler(self, handler_id: int, /) -> None: ...
948+
def do_set_description(self, description: str, /) -> None: ...
949+
def do_set_name(self, name: str, /) -> None: ...
950+
def do_set_parent(self, parent: Object, /) -> None: ...
951+
def do_set_role(self, role: _RoleValueType, /) -> None: ...
952+
def do_state_change(self, name: str, state_set: bool, /) -> None: ...
953953
def do_visible_data_changed(self) -> None: ...
954954
def get_accessible_id(self) -> str: ...
955955
def get_attributes(self) -> list[int]: ...
@@ -1509,7 +1509,7 @@ class Socket(Object, Component):
15091509
accessible_table_summary: Object | None = ...,
15101510
accessible_value: float = ...,
15111511
) -> None: ...
1512-
def do_embed(self, plug_id: str) -> None: ...
1512+
def do_embed(self, plug_id: str, /) -> None: ...
15131513
def embed(self, plug_id: str) -> None: ...
15141514
def is_occupied(self) -> bool: ...
15151515
@classmethod

src/gi-stubs/repository/GObject.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,10 @@ class ParamSpec(_gi.Fundamental):
14841484
def do_set_property(
14851485
self, pspec, value
14861486
): ... # FIXME: Override is missing typing annotation
1487-
def do_value_is_valid(self, value: Any) -> bool: ...
1488-
def do_value_set_default(self, value: Any) -> None: ...
1489-
def do_value_validate(self, value: Any) -> bool: ...
1490-
def do_values_cmp(self, value1: Any, value2: Any) -> int: ...
1487+
def do_value_is_valid(self, value: Any, /) -> bool: ...
1488+
def do_value_set_default(self, value: Any, /) -> None: ...
1489+
def do_value_validate(self, value: Any, /) -> bool: ...
1490+
def do_values_cmp(self, value1: Any, value2: Any, /) -> int: ...
14911491
def get_blurb(self) -> str | None: ...
14921492
def get_default_value(self) -> Any: ...
14931493
def get_name(self) -> str: ...

src/gi-stubs/repository/GdkPixbuf.pyi

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
192192
def get_file_info_async(
193193
filename: str,
194194
cancellable: Gio.Cancellable | None,
195-
callback: Gio.AsyncReadyCallback[None, Unpack[_DataTs]] | None,
195+
callback: Gio._AsyncReadyVarArgsCallback[None, Unpack[_DataTs]] | None,
196196
*user_data: Unpack[_DataTs],
197197
) -> None: ...
198198
@overload
@@ -201,7 +201,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
201201
filename: str,
202202
cancellable: Gio.Cancellable | None = None,
203203
*,
204-
callback: Gio.AsyncReadyCallback[None] | None,
204+
callback: Gio._AsyncReadyVarArgsCallback[None] | None,
205205
) -> None: ...
206206
@staticmethod
207207
def get_file_info_finish(
@@ -285,7 +285,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
285285
def new_from_stream_async(
286286
stream: Gio.InputStream,
287287
cancellable: Gio.Cancellable | None,
288-
callback: Gio.AsyncReadyCallback[None, Unpack[_DataTs]] | None,
288+
callback: Gio._AsyncReadyVarArgsCallback[None, Unpack[_DataTs]] | None,
289289
*user_data: Unpack[_DataTs],
290290
) -> None: ...
291291
@overload
@@ -294,7 +294,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
294294
stream: Gio.InputStream,
295295
cancellable: Gio.Cancellable | None = None,
296296
*,
297-
callback: Gio.AsyncReadyCallback[None] | None,
297+
callback: Gio._AsyncReadyVarArgsCallback[None] | None,
298298
) -> None: ...
299299
@classmethod
300300
def new_from_stream_at_scale(
@@ -312,10 +312,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
312312
height: int,
313313
preserve_aspect_ratio: bool,
314314
cancellable: Gio.Cancellable | None = None,
315-
callback: Callable[
316-
[GObject.Object | None, Gio.AsyncResult, Unpack[_DataTs]], None
317-
]
318-
| None = None,
315+
callback: Gio._AsyncReadyVarArgsCallback[None, Unpack[_DataTs]] | None = None,
319316
*user_data: Unpack[_DataTs],
320317
) -> None: ...
321318
@classmethod
@@ -363,10 +360,7 @@ class Pixbuf(GObject.Object, Gio.Icon, Gio.LoadableIcon):
363360
option_keys: Sequence[str] | None = None,
364361
option_values: Sequence[str] | None = None,
365362
cancellable: Gio.Cancellable | None = None,
366-
callback: Callable[
367-
[GObject.Object | None, Gio.AsyncResult, Unpack[_DataTs]], None
368-
]
369-
| None = None,
363+
callback: Gio._AsyncReadyVarArgsCallback[Pixbuf, Unpack[_DataTs]] | None = None,
370364
*user_data: Unpack[_DataTs],
371365
) -> None: ...
372366
def savev(
@@ -413,8 +407,10 @@ class PixbufAnimation(GObject.Object):
413407
"""
414408
@property
415409
def parent_instance(self) -> GObject.Object: ...
416-
def do_get_iter(self, start_time: GLib.TimeVal | None) -> PixbufAnimationIter: ...
417-
def do_get_size(self, width: int, height: int) -> None: ...
410+
def do_get_iter(
411+
self, start_time: GLib.TimeVal | None, /
412+
) -> PixbufAnimationIter: ...
413+
def do_get_size(self, width: int, height: int, /) -> None: ...
418414
def do_get_static_image(self) -> Pixbuf: ...
419415
def do_is_static_image(self) -> bool: ...
420416
def get_height(self) -> int: ...
@@ -442,7 +438,7 @@ class PixbufAnimation(GObject.Object):
442438
def new_from_stream_async(
443439
stream: Gio.InputStream,
444440
cancellable: Gio.Cancellable | None,
445-
callback: Gio.AsyncReadyCallback[None, Unpack[_DataTs]] | None,
441+
callback: Gio._AsyncReadyVarArgsCallback[None, Unpack[_DataTs]] | None,
446442
*user_data: Unpack[_DataTs],
447443
) -> None: ...
448444
@overload
@@ -451,7 +447,7 @@ class PixbufAnimation(GObject.Object):
451447
stream: Gio.InputStream,
452448
cancellable: Gio.Cancellable | None = None,
453449
*,
454-
callback: Gio.AsyncReadyCallback[None] | None,
450+
callback: Gio._AsyncReadyVarArgsCallback[None] | None,
455451
) -> None: ...
456452
@classmethod
457453
def new_from_stream_finish(
@@ -495,7 +491,7 @@ class PixbufAnimationIter(GObject.Object):
495491
@property
496492
def parent_instance(self) -> GObject.Object: ...
497493
def advance(self, current_time: GLib.TimeVal | None = None) -> bool: ...
498-
def do_advance(self, current_time: GLib.TimeVal | None) -> bool: ...
494+
def do_advance(self, current_time: GLib.TimeVal | None, /) -> bool: ...
499495
def do_get_delay_time(self) -> int: ...
500496
def do_get_pixbuf(self) -> Pixbuf: ...
501497
def do_on_currently_loading_frame(self) -> bool: ...
@@ -581,9 +577,9 @@ class PixbufLoader(GObject.Object):
581577
def priv(self) -> int: ...
582578
def close(self) -> bool: ...
583579
def do_area_prepared(self) -> None: ...
584-
def do_area_updated(self, x: int, y: int, width: int, height: int) -> None: ...
580+
def do_area_updated(self, x: int, y: int, width: int, height: int, /) -> None: ...
585581
def do_closed(self) -> None: ...
586-
def do_size_prepared(self, width: int, height: int) -> None: ...
582+
def do_size_prepared(self, width: int, height: int, /) -> None: ...
587583
def get_animation(self) -> PixbufAnimation | None: ...
588584
def get_format(self) -> PixbufFormat | None: ...
589585
def get_pixbuf(self) -> Pixbuf | None: ...

0 commit comments

Comments
 (0)