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:
@@ -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 Collection, Generator, Iterator, Sequence
|
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.borders import BorderColor
|
||||||
from kitty.fast_data_types import BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, TOP_EDGE
|
from kitty.fast_data_types import BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, TOP_EDGE
|
||||||
|
|||||||
@@ -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
|
from typing import Any, ClassVar, Literal
|
||||||
|
|
||||||
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 = 'axis_y'
|
drag_overlay_mode: ClassVar[Literal['full', 'axis_y', 'axis_x', 'free']] = '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
|
||||||
|
|||||||
@@ -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
|
from typing import Any, ClassVar, Literal
|
||||||
|
|
||||||
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 = 'axis_y'
|
drag_overlay_mode: ClassVar[Literal['full', 'axis_y', 'axis_x', 'free']] = 'axis_y'
|
||||||
main_axis_layout = Layout.ylayout
|
main_axis_layout = Layout.ylayout
|
||||||
perp_axis_layout = Layout.xlayout
|
perp_axis_layout = Layout.xlayout
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user