imprv: generate async overloads for finish-func methods#307
Merged
Conversation
- 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
f865732 to
9d938d1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*_finishfunction and emit three@overloadvariants for each: an awaitable form returning_gi.Async[...], a keyword-only callback form, and a positional callback form with*user_data.Arguments.as_async/as_async_callback_kwargsto derive the visible argument set for each overload, and synthesize aGio.AsyncReadyCallbacktype alias parameterized by the source object type.utils.pymodule: aMISSINGsentinel,get_finish_func, and acache_slotdecorator that lazily populates dataclass slots (works for frozen dataclasses viaobject.__setattr__).class_info.pyandstub.pyto use these helpers, and extendget_namespace_memberto accept aBaseInfo.Fixes #220
Fixes #302