mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Placate mypy
This commit is contained in:
@@ -548,11 +548,11 @@ def main(args: List[str] = sys.argv) -> None:
|
|||||||
parsed_opts.z_index = parse_z_index(cli_opts.z_index)
|
parsed_opts.z_index = parse_z_index(cli_opts.z_index)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise SystemExit(f'Not a valid z-index specification: {cli_opts.z_index}')
|
raise SystemExit(f'Not a valid z-index specification: {cli_opts.z_index}')
|
||||||
try:
|
|
||||||
if cli_opts.background != 'none':
|
if cli_opts.background != 'none':
|
||||||
parsed_opts.remove_alpha = to_color(cli_opts.background, validate=True).as_sharp
|
ra = to_color(cli_opts.background)
|
||||||
except ValueError:
|
if ra is None:
|
||||||
raise SystemExit(f'Not a valid color specification: {cli_opts.background}')
|
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.flip = cli_opts.mirror in ('both', 'vertical')
|
||||||
parsed_opts.flop = cli_opts.mirror in ('both', 'horizontal')
|
parsed_opts.flop = cli_opts.mirror in ('both', 'horizontal')
|
||||||
|
|
||||||
|
|||||||
11
kitty/rgb.py
generated
11
kitty/rgb.py
generated
@@ -3,12 +3,9 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Optional, overload, TYPE_CHECKING
|
from typing import Optional
|
||||||
from .fast_data_types import Color
|
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:
|
def alpha_blend_channel(top_color: int, bottom_color: int, alpha: float) -> int:
|
||||||
return int(alpha * top_color + (1 - alpha) * bottom_color)
|
return int(alpha * top_color + (1 - alpha) * bottom_color)
|
||||||
@@ -59,12 +56,6 @@ def color_as_sgr(x: Color) -> str:
|
|||||||
return x.as_sgr
|
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]:
|
def to_color(raw: str, validate: bool = False) -> Optional[Color]:
|
||||||
# See man XParseColor
|
# See man XParseColor
|
||||||
x = raw.strip().lower()
|
x = raw.strip().lower()
|
||||||
|
|||||||
Reference in New Issue
Block a user