Skip to content

Conversation

@devbutlazy
Copy link

Summary

Fix #1488 => in ColourConverter.convert where certain classmethods (like holographic_style) return a tuple of colors instead of a single disnake.Color instance. Previously, this caused the converter to return a tuple instead of raising an error.

This PR adds a type check after invoking the color method and raises BadColourArgument if the returned value is not a single disnake.Color.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s pyright
  • This PR fixes an issue
  • 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, ...)

@Enegg
Copy link
Contributor

Enegg commented Dec 19, 2025

The fix you are proposing is a band-aid. The library shouldn't be invoking any non-factory methods of Color in the first place. Invoking them and only then checking the return type can lead to bugs in the future (what if a method was added that mutates some state?)

To properly fix the issue, we should have some kind of mapping of valid names to the methods, or at least a set to validate input beforehand.

@devbutlazy
Copy link
Author

devbutlazy commented Dec 20, 2025

To properly fix the issue, we should have some kind of mapping of valid names to the methods, or at least a set to validate input beforehand.

If you provide such a set, I'd implement the proper issue fix.

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.

commands.ColourConverter can return Colour.holographic_style()

2 participants