Skip to content

imprv: generate async overloads for finish-func methods#307

Merged
bryanforbes merged 1 commit into
pygobject:masterfrom
bryanforbes:feat/generic-async
May 14, 2026
Merged

imprv: generate async overloads for finish-func methods#307
bryanforbes merged 1 commit into
pygobject:masterfrom
bryanforbes:feat/generic-async

Conversation

@bryanforbes
Copy link
Copy Markdown
Collaborator

@bryanforbes bryanforbes commented May 14, 2026

  • Detect callable methods that have a paired *_finish function and emit three @overload variants for each: an awaitable form returning _gi.Async[...], a keyword-only callback form, and a positional callback form with *user_data.
  • Add Arguments.as_async / as_async_callback_kwargs to derive the visible argument set for each overload, and synthesize a Gio.AsyncReadyCallback type alias parameterized by the source object type.
  • Add helpers to the utils.py module: a MISSING sentinel, get_finish_func, and a cache_slot decorator that lazily populates dataclass slots (works for frozen dataclasses via object.__setattr__).
  • Refactor class_info.py and stub.py to use these helpers, and extend get_namespace_member to accept a BaseInfo.

Fixes #220
Fixes #302

- Detect callable methods that have a paired `*_finish` function
  and emit three `@overload` variants for each: an awaitable form
  returning `_gi.Async[...]`, a keyword-only callback form, and a
  positional callback form with `*user_data`.
- Add `Arguments.as_async` / `as_async_callback_kwargs` to derive
  the visible argument set for each overload, and synthesize a
  `Gio.AsyncReadyCallback` type alias parameterized by the source
  object type.
- Add helpers to the `utils.py` module: a `MISSING` sentinel,
  `get_finish_func`, and a `cache_slot` decorator that lazily populates
  dataclass slots (works for frozen dataclasses via
  `object.__setattr__`).
- Refactor `class_info.py` and `stub.py` to use these helpers, and
  extend `get_namespace_member` to accept a `BaseInfo`.

Fixes pygobject#220
Fixes pygobject#302
@bryanforbes bryanforbes force-pushed the feat/generic-async branch from f865732 to 9d938d1 Compare May 14, 2026 23:47
@bryanforbes bryanforbes merged commit 104b612 into pygobject:master May 14, 2026
2 checks passed
@bryanforbes bryanforbes deleted the feat/generic-async branch May 14, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async Callbacks always raise errors Type async method return values correctly

1 participant