interactions.py
interactions.py copied to clipboard
fix: don't pass kwargs to modal callbacks that only have ctx
Pull Request Type
- [ ] Feature addition
- [x] Bugfix
- [ ] Documentation update
- [ ] Code refactor
- [ ] Tests improvement
- [ ] CI/CD pipeline enhancement
- [ ] Other: [Replace with a description]
Description
This PR fixes #1517 by making sure ctx.kwargs
is not passed into modal callbacks. Unlike #1584, this PR only does so if the only argument in the modal callback is ctx
(and self
).
Changes
- Add an attribute to
ModalCommand
to note if the callback just hasctx
or has more parameters at play. - When adding modal callbacks, check how many parameters the callback has, excluding
ctx
andself
. If there are no parameters, enable the above attribute. - Make
ModalCommand
pass in no kwargs if the attribute is enabled.
Related Issues
Fixes #1517. A non-breaking, superseding alternative to #1584.
Test Scenarios
See #1517 for an example.
Python Compatibility
- [ ] I've ensured my code works on Python
3.10.x
- [x] I've ensured my code works on Python
3.11.x
Checklist
- [x] I've run the
pre-commit
code linter over all edited files - [x] I've tested my changes on supported Python versions
- [ ] I've added tests for my code, if applicable
- [ ] I've updated / added documentation, where applicable