Placate mypy

This commit is contained in:
Kovid Goyal 2022-01-14 22:26:05 +05:30
parent 4ce6d718c9
commit 58da5d4d29
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 15 deletions

View File

@ -548,11 +548,11 @@ def main(args: List[str] = sys.argv) -> None:
parsed_opts.z_index = parse_z_index(cli_opts.z_index)
except Exception:
raise SystemExit(f'Not a valid z-index specification: {cli_opts.z_index}')
try:
if cli_opts.background != 'none':
parsed_opts.remove_alpha = to_color(cli_opts.background, validate=True).as_sharp
except ValueError:
raise SystemExit(f'Not a valid color specification: {cli_opts.background}')
if cli_opts.background != 'none':
ra = to_color(cli_opts.background)
if ra is None:
raise SystemExit(f'Not a valid color specification: {cli_opts.background}')
parsed_opts.remove_alpha = ra.as_sharp
parsed_opts.flip = cli_opts.mirror in ('both', 'vertical')
parsed_opts.flop = cli_opts.mirror in ('both', 'horizontal')

11
kitty/rgb.py generated
View File

@ -3,12 +3,9 @@
import re
from contextlib import suppress
from typing import Optional, overload, TYPE_CHECKING
from typing import Optional
from .fast_data_types import Color
if TYPE_CHECKING:
from typing import Literal
def alpha_blend_channel(top_color: int, bottom_color: int, alpha: float) -> int:
return int(alpha * top_color + (1 - alpha) * bottom_color)
@ -59,12 +56,6 @@ def color_as_sgr(x: Color) -> str:
return x.as_sgr
@overload
def to_color(raw: str, validate: 'Literal[True]' = True) -> Color: ...
@overload
def to_color(raw: str, validate: 'Literal[False]' = False) -> Optional[Color]: ...
def to_color(raw: str, validate: bool = False) -> Optional[Color]:
# See man XParseColor
x = raw.strip().lower()