interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
838 stars 184 forks source link

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

Closed Scrxtchy closed 6 months ago

Scrxtchy commented 6 months ago

Pull Request Type

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

Checklist