summaryrefslogtreecommitdiff
path: root/poezio/colors.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-14 22:31:22 +0100
committermathieui <mathieui@mathieui.net>2021-04-02 17:44:36 +0200
commit4b198be9771594a28824cc082e737fe15ab681ec (patch)
tree01de648647136734d176ba0fa33e96a61bbafc88 /poezio/colors.py
parentbc4f4f1e0766aedb6b0e9f3df90fee9ea841786c (diff)
downloadpoezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.gz
poezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.bz2
poezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.xz
poezio-4b198be9771594a28824cc082e737fe15ab681ec.zip
fix: tons of type errors
Diffstat (limited to 'poezio/colors.py')
-rw-r--r--poezio/colors.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/poezio/colors.py b/poezio/colors.py
index adb2ca40..346e1fd0 100644
--- a/poezio/colors.py
+++ b/poezio/colors.py
@@ -1,4 +1,4 @@
-from typing import Tuple, Dict, List
+from typing import Tuple, Dict, List, Union
import curses
import hashlib
import math
@@ -15,6 +15,9 @@ K_B = 1 - K_R - K_G
def ncurses_color_to_rgb(color: int) -> Tuple[float, float, float]:
if color <= 15:
+ r: Union[int, float]
+ g: Union[int, float]
+ b: Union[int, float]
try:
(r, g, b) = curses.color_content(color)
except: # fallback in faulty terminals (e.g. xterm)
@@ -83,6 +86,9 @@ def ccg_palette_lookup(palette: Palette, angle: float) -> int:
best_metric = metric
best = color
+ if best is None:
+ raise ValueError("No color in palette")
+
return best