From 0d27a54835801ee0729a53150415f588bdb7eaff Mon Sep 17 00:00:00 2001 From: 3alTemp Date: Sun, 3 Mar 2024 20:52:18 -0600 Subject: [PATCH] MyPy is YourPy --- src/assets/ba_data/python/bauiv1lib/colorpicker.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/assets/ba_data/python/bauiv1lib/colorpicker.py b/src/assets/ba_data/python/bauiv1lib/colorpicker.py index b6bbd2fb..c7e57b2e 100644 --- a/src/assets/ba_data/python/bauiv1lib/colorpicker.py +++ b/src/assets/ba_data/python/bauiv1lib/colorpicker.py @@ -319,7 +319,11 @@ class ColorPickerExact(PopupWindow): if hextext != self._hex_prev_text: try: hexcolor = hex_to_color(hextext) - r, g, b, _ = hexcolor + if len(hexcolor) == 4: + r, g, b, a = hexcolor + del a # unused + else: + r, g, b = hexcolor # Replace the color! for i, ch in enumerate((r, g, b)): self._color[i] = max(0.0, min(1.0, ch)) @@ -422,11 +426,9 @@ def hex_to_color(hex_color: str) -> tuple: (int.from_bytes(bytes.fromhex(hex_color[0:2]))), (int.from_bytes(bytes.fromhex(hex_color[2:4]))), (int.from_bytes(bytes.fromhex(hex_color[4:6]))), - ( - int.from_bytes(bytes.fromhex(hex_color[6:8])) - if hexlength == 8 - else 255 - ), + (int.from_bytes(bytes.fromhex(hex_color[6:8]))) + if hexlength == 8 + else None, ) # Divide all numbers by 255 and return. nr, ng, nb, na = (x / 255 if x is not None else None for x in (ar, ag, ab, aa))