Fix mypy error: remove narrowing ClassVar[Literal] annotations from layout subclasses

Horizontal extends Vertical, and Fat extends Tall. Declaring
drag_overlay_mode with a narrower Literal type in the subclass
conflicts with the parent's declared type, causing mypy error
"Incompatible types in assignment". Since the base Layout class already
declares the full union type, subclasses only need a bare assignment.

Also removes now-unused ClassVar and Literal imports from vertical.py,
tall.py, and grid.py.
This commit is contained in:
mcrmck
2026-03-27 02:17:59 -04:00
parent a368a90e37
commit d1b8df6975
4 changed files with 9 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ from collections.abc import Callable, Generator, Iterator, Sequence
from functools import lru_cache from functools import lru_cache
from itertools import repeat from itertools import repeat
from math import ceil, floor from math import ceil, floor
from typing import Any, ClassVar, Literal from typing import Any
from kitty.borders import BorderColor from kitty.borders import BorderColor
from kitty.types import Edges, NeighborsMap, WindowMapper from kitty.types import Edges, NeighborsMap, WindowMapper
@@ -34,7 +34,7 @@ class Grid(Layout):
name: str = 'grid' name: str = 'grid'
no_minimal_window_borders = True no_minimal_window_borders = True
drag_overlay_mode: ClassVar[Literal['axis_y']] = 'axis_y' drag_overlay_mode = 'axis_y'
def remove_all_biases(self) -> bool: def remove_all_biases(self) -> bool:
self.biased_rows: dict[int, float] = {} self.biased_rows: dict[int, float] = {}

View File

@@ -561,7 +561,7 @@ class Splits(Layout):
needs_all_windows = True needs_all_windows = True
layout_opts = SplitsLayoutOpts({}) layout_opts = SplitsLayoutOpts({})
no_minimal_window_borders = True no_minimal_window_borders = True
drag_overlay_mode: ClassVar[Literal['free']] = 'free' drag_overlay_mode = 'free'
@property @property
def default_axis_is_horizontal(self) -> bool | None: def default_axis_is_horizontal(self) -> bool | None:

View File

@@ -4,7 +4,7 @@
import sys import sys
from collections.abc import Generator, Iterator, Sequence from collections.abc import Generator, Iterator, Sequence
from itertools import islice, repeat from itertools import islice, repeat
from typing import Any, ClassVar, Literal from typing import Any
from kitty.borders import BorderColor from kitty.borders import BorderColor
from kitty.conf.utils import to_bool from kitty.conf.utils import to_bool
@@ -136,7 +136,7 @@ class Tall(Layout):
name = 'tall' name = 'tall'
main_is_horizontal = True main_is_horizontal = True
no_minimal_window_borders = True no_minimal_window_borders = True
drag_overlay_mode: ClassVar[Literal['axis_y']] = 'axis_y' drag_overlay_mode = 'axis_y'
layout_opts = TallLayoutOpts({}) layout_opts = TallLayoutOpts({})
main_axis_layout = Layout.xlayout main_axis_layout = Layout.xlayout
perp_axis_layout = Layout.ylayout perp_axis_layout = Layout.ylayout
@@ -382,6 +382,6 @@ class Fat(Tall):
name = 'fat' name = 'fat'
main_is_horizontal = False main_is_horizontal = False
drag_overlay_mode: ClassVar[Literal['axis_x']] = 'axis_x' drag_overlay_mode = 'axis_x'
main_axis_layout = Layout.ylayout main_axis_layout = Layout.ylayout
perp_axis_layout = Layout.xlayout perp_axis_layout = Layout.xlayout

View File

@@ -2,7 +2,7 @@
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net> # License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Generator, Iterable from collections.abc import Generator, Iterable
from typing import Any, ClassVar, Literal from typing import Any
from kitty.borders import BorderColor from kitty.borders import BorderColor
from kitty.types import Edges, NeighborsMap, WindowMapper from kitty.types import Edges, NeighborsMap, WindowMapper
@@ -64,7 +64,7 @@ class Vertical(Layout):
name = 'vertical' name = 'vertical'
main_is_horizontal = False main_is_horizontal = False
no_minimal_window_borders = True no_minimal_window_borders = True
drag_overlay_mode: ClassVar[Literal['axis_y']] = 'axis_y' drag_overlay_mode = 'axis_y'
main_axis_layout = Layout.ylayout main_axis_layout = Layout.ylayout
perp_axis_layout = Layout.xlayout perp_axis_layout = Layout.xlayout
@@ -156,6 +156,6 @@ class Horizontal(Vertical):
name = 'horizontal' name = 'horizontal'
main_is_horizontal = True main_is_horizontal = True
drag_overlay_mode: ClassVar[Literal['axis_x']] = 'axis_x' drag_overlay_mode = 'axis_x'
main_axis_layout = Layout.xlayout main_axis_layout = Layout.xlayout
perp_axis_layout = Layout.ylayout perp_axis_layout = Layout.ylayout