Last active
April 17, 2026 23:54
-
-
Save weishi-imbue/6d4e90029678605ad7ddcba6a3d7fe4c to your computer and use it in GitHub Desktop.
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
| def _parse_value(self, val: str, maxval: int = 255) -> int: | |
| try: | |
| return int(val) | |
| except ValueError: | |
| pass | |
| if val.endswith('%'): | |
| val = val[:-1] | |
| - mult = maxval / 100 | |
| + try: | |
| + return round(float(val) * maxval / 100) | |
| + except ValueError: | |
| + raise configexc.ValidationError(val, "must be a valid color value") | |
| else: | |
| - mult = maxval / 1.0 | |
| - | |
| - try: | |
| - return int(float(val) * mult) | |
| - except ValueError: | |
| - raise configexc.ValidationError(val, "must be a valid color value") | |
| + try: | |
| + return round(float(val)) | |
| + except ValueError: | |
| + raise configexc.ValidationError(val, "must be a valid color value") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error in line 22.
When input val = '1.0', representing the alpha (transparency) channel, expected output is 255, not 1.