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:
parent
a368a90e37
commit
d1b8df6975
4 changed files with 9 additions and 9 deletions
|
|
@ -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] = {}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue