Repository navigation
Fix none hue output when the angle unit is not degrees - #531
Merged
facelessuser merged 2 commits intoOct 20, 2026
Merged
Conversation
An undefined hue was written with the `angle` unit appended, such as `hsl(noneturn 50 50)`. That is not valid CSS and cannot be parsed back.
Owner
|
Please add a note in the change log. |
Contributor
Author
|
Added a changelog entry under |
Owner
|
@gir-bot lgtm |
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.
to_string()appends theangleunit to an undefined hue:noneturnis not valid CSS, andColor()cannot read it back. The strings docs say undefined channels "can be displayed asnone" on output, so the result should behsl(none 50 50).radandgraddo the same, and so doescolor=True.deghas no suffix, so it was already correct.anglewas added in 6.1. I ran the example on every tag from 6.1 to 8.13.1 and all of them give the wrong result.color_functionadds the unit whether or not the value isNaN(serialize.py#L105).Color.__repr__already leaves the unit off forNaN, and the fix does the same.Test:
pytest tests/test_api.py -k test_to_string_anglefails on main with'hsl(nonerad 50 50)' != 'hsl(none 50 50)'and passes with the change.