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

Allow all color types mask.from_threshold and fix typing for PixelArray methods #3164

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

damusss
Copy link
Member

@damusss damusss commented Oct 10, 2024

I understand why slice-assignment of pixelarrays limits the allowed types, but this was likely not intended for the replace() and extract() methods, as they were typehinted with ColorValue but don't currently allow all color values.
This PR adds a C function specifically for those methods, making the typehints true.

The same thing applies to mask.from_threshold.

If you think they should not accept all color types, I can change the PR to change the typehints instead, of course.

@damusss damusss added PixelArray pygame.PixelArray bugfix PR that fixes bug labels Oct 10, 2024
@damusss damusss requested a review from a team as a code owner October 10, 2024 17:14
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

As a matter of personal preference, I would like to have consistent handling within pixelarray for color values. As it is sort of documented at the module level, it would make sense to keep that behaviour everywhere in the module. Therefore I think this case is a "stubs should be fixed" thing

The mask change on the other hand, I am fine with.

@damusss
Copy link
Member Author

damusss commented Nov 16, 2024

@ankith26 I had actually forgot of this, now it should be ready

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR 🎉

@ankith26 ankith26 changed the title Allow all color types for PixelArray methods and mask.from_threshold Allow all color types mask.from_threshold and fix typing for PixelArray methods Nov 18, 2024
Copy link
Member

@zoldalma999 zoldalma999 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@zoldalma999 zoldalma999 merged commit 28db8df into pygame-community:main Nov 19, 2024
25 checks passed
@zoldalma999 zoldalma999 added this to the 2.5.3 milestone Nov 19, 2024
@damusss damusss deleted the fix-color-typehint branch November 19, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR that fixes bug PixelArray pygame.PixelArray
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants