fix(colors): str2bgra() silently ignored its alpha argument#316
Open
ywatanabe1989 wants to merge 1 commit into
Open
fix(colors): str2bgra() silently ignored its alpha argument#316ywatanabe1989 wants to merge 1 commit into
ywatanabe1989 wants to merge 1 commit into
Conversation
str2bgra(c, alpha=...) accepted alpha but called str2rgba(c) without it, so every BGRA colour came back fully opaque no matter what the caller asked for. str2rgba already honours the parameter, and the deprecated to_rgba wrapper shows the intended call shape (str2rgba(c, alpha=alpha)). Pass alpha through, and add regression tests covering the explicit alpha, the opaque default, and the channel order against str2rgba.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
str2bgra()accepted analphaargument and then discarded it, so the returned alpha channel was always 1.0 regardless of what the caller passed.Why this looks unintended rather than deliberate
str2rgba(c, alpha=1.0)(same file, L21-24) does honour the parameter.to_rgba(L177) callsstr2rgba(c, alpha=alpha)— the intended shape.The fix
One line: forward
alphathrough. Blast radius is zero —str2bgrais referenced only at its own definition and is not re-exported fromcolors/__init__.py.Verification (run in both directions)
assert 1.0 == 0.3tests/figrecipe/colors/suite is greenThree regression tests added: alpha is honoured, the default stays opaque, and channel order is pinned against
str2rgbaso a later change cannot silently swap B and R.Note for maintainers
This repo's
.venvis broken inside the agent container (bin/python3.11is a dangling symlink; only 3.12 is present), so the tests had to be run through a throwaway 3.12 venv. Reported separately — it is independent of this change.Found while surveying the codebase for newcomer-friendly issues.