From ee16b14c735a963a4d7ea0c2d5cd0db13c33c7fc Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 30 May 2024 10:57:39 -0700 Subject: [PATCH] Fix some mypy type errors in cli.py Signed-off-by: Alek Ratzloff --- colorhash/cli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/colorhash/cli.py b/colorhash/cli.py index f539350..6c7efc6 100644 --- a/colorhash/cli.py +++ b/colorhash/cli.py @@ -7,7 +7,7 @@ import textwrap from .colorizer import PaletteColorizer from .matricizer import Matricizer, NibbleMatricizer, RandomartMatricizer -from .palettes import DEFAULT_PALETTES, PALETTES +from .palettes import Palette, DEFAULT_PALETTES, PALETTES from .svg import gensvg @@ -136,7 +136,10 @@ def cli_main() -> None: # TODO - pretty error message for when the file doesn't exist infile = open(args.input, "rb") # file_digest (I hope) will not load too much into memory - hashdata = hashlib.file_digest(infile, args.hash).digest() + hashdata = hashlib.file_digest(infile, args.hash).digest() # type: ignore + # NOTE : previous line has typing ignored because file_digest requires a + # "_BytesIOLike | _FileDigestFileObj", both of which look like API leaks. Specifying + # infile to be BinaryIO is not enough and causes the same error. case "hash": # TODO - maybe a better error message? if args.hash is None: @@ -167,7 +170,7 @@ def cli_main() -> None: assert False, f"invalid args.matrix: {args.matrix}" # Choose the palette - palette: list[str] + palette: Palette if args.palette == "auto": palette = matricizer.choose_palette(hashdata) else: