pycord icon indicating copy to clipboard operation
pycord copied to clipboard

feat: :sparkles: Allow for `functools.partial` and functions returning an awaitable as autocomplete

Open Paillat-dev opened this issue 11 months ago • 4 comments

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

  • [x] This PR fixes an issue.
  • [x] 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

  • [x] I have searched the open pull requests for duplicates.
  • [x] 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.
  • [x] I have updated the changelog to include these changes.

Paillat-dev avatar Dec 12 '24 22:12 Paillat-dev

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

Paillat-dev avatar Dec 12 '24 22:12 Paillat-dev

@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 https://github.com/Pycord-Development/pycord/issues/2668#issuecomment-2540044621, I do think partials make sense in many contexts, and it would be great to have support for those who need something quick.

DefiDebauchery avatar Dec 12 '24 22:12 DefiDebauchery

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

plun1331 avatar Dec 13 '24 04:12 plun1331

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

Paillat-dev avatar Dec 14 '24 11:12 Paillat-dev

Merge conflicts

Lulalaby avatar Aug 02 '25 03:08 Lulalaby

Fixed

Paillat-dev avatar Aug 02 '25 16:08 Paillat-dev

tbh I might as well give up this one and make it part of the options rewrite in next

Paillat-dev avatar Sep 01 '25 13:09 Paillat-dev

idk. we dunno when next comes out. i'd prefer if we still have it here

Lulalaby avatar Sep 01 '25 13:09 Lulalaby

It's just that I don't really like that code I wrote but at the same time it's mainly because options are spaghetti code

Paillat-dev avatar Sep 01 '25 13:09 Paillat-dev

This breaks autocomplete, please hold

Paillat-dev avatar Sep 05 '25 11:09 Paillat-dev