Skip to content
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

feat: ✨ Allow for functools.partial and functions returning an awaitable as autocomplete #2669

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Paillat-dev
Copy link
Contributor

@Paillat-dev Paillat-dev commented Dec 12, 2024

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

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Paillat-dev Paillat-dev requested a review from a team as a code owner December 12, 2024 22:10
@pullapprove4 pullapprove4 bot requested a review from Middledot December 12, 2024 22:10
@Paillat-dev Paillat-dev changed the title ✨ Allow for functools.partials and such as autocomplete feat: ✨ Allow for functools.partials and such as autocomplete Dec 12, 2024
@Paillat-dev
Copy link
Contributor Author

@DefiDebauchery Would you mind testing this pr with your usecase and functools.partial?

@DefiDebauchery
Copy link
Contributor

@DefiDebauchery Would you mind testing this pr with your usecase and functools.partial?

Yes, this did work on my side, thank you! While I also like the solution offered in #2668 (comment), I do think partials make sense in many contexts, and it would be great to have support for those who need something quick.

@plun1331
Copy link
Member

https://discord.com/channels/881207955029110855/881735314987708456/1316992273476747375

@Paillat-dev Paillat-dev changed the title feat: ✨ Allow for functools.partials and such as autocomplete feat: ✨ Allow for functools.partials functions returning an awaitable as autocomplete Dec 13, 2024
@Paillat-dev Paillat-dev changed the title feat: ✨ Allow for functools.partials functions returning an awaitable as autocomplete feat: ✨ Allow for functools.partial functions returning an awaitable as autocomplete Dec 13, 2024
@Paillat-dev Paillat-dev changed the title feat: ✨ Allow for functools.partial functions returning an awaitable as autocomplete feat: ✨ Allow for functools.partial and functions returning an awaitable as autocomplete Dec 13, 2024
@Paillat-dev Paillat-dev marked this pull request as ready for review December 13, 2024 08:08
@Paillat-dev
Copy link
Contributor Author

Oh shoot checks failing... This is why we should be using Annotated for options...

examples/app_commands/slash_partial_autocomplete.py Outdated Show resolved Hide resolved
examples/app_commands/slash_partial_autocomplete.py Outdated Show resolved Hide resolved
discord/commands/options.py Outdated Show resolved Hide resolved
discord/commands/options.py Outdated Show resolved Hide resolved
@Paillat-dev Paillat-dev requested a review from DA-344 December 14, 2024 14:58
discord/commands/options.py Outdated Show resolved Hide resolved
@Paillat-dev Paillat-dev force-pushed the partial-autocomplete branch 2 times, most recently from 9c80445 to 6ec28e1 Compare December 15, 2024 09:27
examples/app_commands/slash_partial_autocomplete.py Outdated Show resolved Hide resolved
examples/app_commands/slash_partial_autocomplete.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
discord/commands/options.py Outdated Show resolved Hide resolved
Comment on lines +39 to +40
- Added the ability to use functions with any number of optional arguments, and
functions returning an awaitable as `Option.autocomplete`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Added the ability to use functions with any number of optional arguments, and
functions returning an awaitable as `Option.autocomplete`.
- Added the ability to use functions with any number of optional arguments and
functions returning an awaitable as `Option.autocomplete`.

Redundant comma

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not be merged with the current autocomplete example?

Copy link
Member

@Dorukyum Dorukyum Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ need explanations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Somehow) Allow autocomplete methods to accept arguments
6 participants