From d1b8df697541eeab46555c9e9e2c0d09b2a1c7fc Mon Sep 17 00:00:00 2001 From: mcrmck Date: Fri, 27 Mar 2026 02:17:59 -0400 Subject: [PATCH] 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. --- kitty/layout/grid.py | 4 ++-- kitty/layout/splits.py | 2 +- kitty/layout/tall.py | 6 +++--- kitty/layout/vertical.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kitty/layout/grid.py b/kitty/layout/grid.py index c34a22671..5a7fcda9c 100644 --- a/kitty/layout/grid.py +++ b/kitty/layout/grid.py @@ -5,7 +5,7 @@ from functools import lru_cache from itertools import repeat from math import ceil, floor -from typing import Any, ClassVar, Literal +from typing import Any from kitty.borders import BorderColor from kitty.types import Edges, NeighborsMap, WindowMapper @@ -34,7 +34,7 @@ class Grid(Layout): name: str = 'grid' 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: self.biased_rows: dict[int, float] = {} diff --git a/kitty/layout/splits.py b/kitty/layout/splits.py index 617d9681b..b7bbaa92a 100644 --- a/kitty/layout/splits.py +++ b/kitty/layout/splits.py @@ -561,7 +561,7 @@ class Splits(Layout): needs_all_windows = True layout_opts = SplitsLayoutOpts({}) no_minimal_window_borders = True - drag_overlay_mode: ClassVar[Literal['free']] = 'free' + drag_overlay_mode = 'free' @property def default_axis_is_horizontal(self) -> bool | None: diff --git a/kitty/layout/tall.py b/kitty/layout/tall.py index f2ee2717e..2a1f1f614 100644 --- a/kitty/layout/tall.py +++ b/kitty/layout/tall.py @@ -4,7 +4,7 @@ import sys from collections.abc import Generator, Iterator, Sequence from itertools import islice, repeat -from typing import Any, ClassVar, Literal +from typing import Any from kitty.borders import BorderColor from kitty.conf.utils import to_bool @@ -136,7 +136,7 @@ class Tall(Layout): name = 'tall' main_is_horizontal = True no_minimal_window_borders = True - drag_overlay_mode: ClassVar[Literal['axis_y']] = 'axis_y' + drag_overlay_mode = 'axis_y' layout_opts = TallLayoutOpts({}) main_axis_layout = Layout.xlayout perp_axis_layout = Layout.ylayout @@ -382,6 +382,6 @@ class Fat(Tall): name = 'fat' main_is_horizontal = False - drag_overlay_mode: ClassVar[Literal['axis_x']] = 'axis_x' + drag_overlay_mode = 'axis_x' main_axis_layout = Layout.ylayout perp_axis_layout = Layout.xlayout diff --git a/kitty/layout/vertical.py b/kitty/layout/vertical.py index 7f0d55e7d..c69dde0dd 100644 --- a/kitty/layout/vertical.py +++ b/kitty/layout/vertical.py @@ -2,7 +2,7 @@ # License: GPLv3 Copyright: 2020, Kovid Goyal from collections.abc import Generator, Iterable -from typing import Any, ClassVar, Literal +from typing import Any from kitty.borders import BorderColor from kitty.types import Edges, NeighborsMap, WindowMapper @@ -64,7 +64,7 @@ class Vertical(Layout): name = 'vertical' main_is_horizontal = False no_minimal_window_borders = True - drag_overlay_mode: ClassVar[Literal['axis_y']] = 'axis_y' + drag_overlay_mode = 'axis_y' main_axis_layout = Layout.ylayout perp_axis_layout = Layout.xlayout @@ -156,6 +156,6 @@ class Horizontal(Vertical): name = 'horizontal' main_is_horizontal = True - drag_overlay_mode: ClassVar[Literal['axis_x']] = 'axis_x' + drag_overlay_mode = 'axis_x' main_axis_layout = Layout.xlayout perp_axis_layout = Layout.ylayout