mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-22 13:12:23 +00:00
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.
This commit is contained in:
parent
d1b8df6975
commit
6c37c1c391
3 changed files with 5 additions and 5 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue