From 6c37c1c391d46ce17cc42df6a55583042f1c8fdf Mon Sep 17 00:00:00 2001 From: mcrmck Date: Fri, 27 Mar 2026 02:25:35 -0400 Subject: [PATCH] Fix mypy: annotate drag_overlay_mode with full union type in Vertical and Tall Bare literal assignments (drag_overlay_mode = 'axis_y') cause mypy to narrow-infer the type as Literal['axis_y'] on the parent class, making the subclass override (Horizontal = 'axis_x', Fat = 'axis_x') an incompatible assignment. Fix by explicitly annotating Vertical and Tall with the full union type from the base class, so the declared type stays wide and subclasses can freely assign any valid mode. Also removes unused ClassVar/Literal imports from splits.py. --- kitty/layout/splits.py | 2 +- kitty/layout/tall.py | 4 ++-- kitty/layout/vertical.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kitty/layout/splits.py b/kitty/layout/splits.py index b7bbaa92a..67fa6ff25 100644 --- a/kitty/layout/splits.py +++ b/kitty/layout/splits.py @@ -2,7 +2,7 @@ # License: GPLv3 Copyright: 2020, Kovid Goyal from collections.abc import Collection, Generator, Iterator, Sequence -from typing import Any, ClassVar, Literal, Optional, TypedDict, Union +from typing import Any, Optional, TypedDict, Union from kitty.borders import BorderColor from kitty.fast_data_types import BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, TOP_EDGE diff --git a/kitty/layout/tall.py b/kitty/layout/tall.py index 2a1f1f614..d2f6515e2 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 +from typing import Any, ClassVar, Literal 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 = 'axis_y' + drag_overlay_mode: ClassVar[Literal['full', 'axis_y', 'axis_x', 'free']] = 'axis_y' layout_opts = TallLayoutOpts({}) main_axis_layout = Layout.xlayout perp_axis_layout = Layout.ylayout diff --git a/kitty/layout/vertical.py b/kitty/layout/vertical.py index c69dde0dd..82513f30a 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 +from typing import Any, ClassVar, Literal 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 = 'axis_y' + drag_overlay_mode: ClassVar[Literal['full', 'axis_y', 'axis_x', 'free']] = 'axis_y' main_axis_layout = Layout.ylayout perp_axis_layout = Layout.xlayout