-
-
Notifications
You must be signed in to change notification settings - Fork 481
feat: ✨ Allow for functools.partial
and functions returning an awaitable as autocomplete
#2914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Paillat <me@paillat.dev>
Signed-off-by: Paillat <me@paillat.dev>
Signed-off-by: Paillat <me@paillat.dev>
Signed-off-by: Paillat <me@paillat.dev>
Signed-off-by: Paillat <paillat@pycord.dev>
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/2914/head:pr-2914
git checkout pr-2914 This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2914/head |
Ok this is kind of spaghetti code, but I mean it works... In next autocompletes should probably be made into classes and it should make most of this mess clearer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for using functools.partial
and functions returning awaitables as autocomplete handlers for Discord application commands. The key enhancement is making the autocomplete system more flexible by allowing functions with optional parameters and improving the detection of async behavior.
- Enhanced autocomplete function signature detection to support functions with optional parameters
- Improved async handling by checking for awaitable results instead of just coroutine functions
- Added example demonstrating the use of
functools.partial
for autocomplete
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
examples/app_commands/slash_autocomplete.py | Added example demonstrating functools.partial usage with autocomplete |
discord/commands/options.py | Enhanced type annotations and added property-based autocomplete with signature analysis |
discord/commands/core.py | Updated autocomplete invocation to use pre-computed method detection and improved async handling |
CHANGELOG.md | Added changelog entry documenting the new functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Signed-off-by: Paillat <paillat@pycord.dev>
Signed-off-by: Paillat <jeremiecotti@ik.me>
Summary
Allows usage of functions with any number of optional parameters as autocomplete. This allows by extent the usage of partials and similar as autocomplete.
Fixes #2668
Superseeds #2669
Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.