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

fix: adjust DistinctFlag.__call__ for python 3.12.3+ #1659

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

Scrxtchy
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Due to a change allowing Enums to have None as a value, the default value has changed to support this feature. However this has broken the DistinctFlag.__call__ used by interactions.py which explicity uses None as a name as the default making this a breaking change. By adjusting the function to not rely on a hard-coded default value we can support both a custom name as well as the new default while maintaining compatibility for old versions of python

Changes

Adjusted DistinctFlag.__call__ to call its super with kwargs that are previously defined based on the function call. If the default value is given, we throw them out, but if a non-default value is used, kwargs is filled with the ``names` parameter appropriately to be passed to the super

Related Issues

Fixes #1657

Test Scenarios

import interactions
interactions.Intents(0)

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x
  • I've ensured my code works on Python 3.12.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

As None is a valid value now, as of 3.12.3 it cannot be used
for the name python/cpython#116040
Copy link
Member

@silasary silasary left a comment

Choose a reason for hiding this comment

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

Elegant

@eightween eightween merged commit 9788eb4 into interactions-py:unstable Apr 20, 2024
2 checks passed
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