Skip to content

fix: don't pass kwargs to modal callbacks that only have ctx #1619

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

Merged

Conversation

AstreaTSS
Copy link
Member

Pull Request Type

  • Feature addition
  • 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 has ctx or has more parameters at play.
  • When adding modal callbacks, check how many parameters the callback has, excluding ctx and self. 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
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • 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

@eightween eightween enabled auto-merge (squash) March 30, 2024 07:52
Signed-off-by: Astrea <25420078+AstreaTSS@users.noreply.github.com>
@eightween eightween merged commit 23a695b into interactions-py:unstable Apr 24, 2024
1 of 2 checks passed
@AstreaTSS AstreaTSS deleted the non-breaking-modal-callback-fix branch April 24, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants