Get rid of some obsolete TypeVar usages

This commit is contained in:
Kovid Goyal 2026-07-07 14:01:30 +05:30
parent 8860f1a0a7
commit 1543831a1c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 7 additions and 11 deletions

View file

@ -152,7 +152,7 @@ from .session import (
from .shaders import load_shader_programs
from .simple_cli_definitions import grab_keyboard_docs
from .tabs import SpecialWindow, SpecialWindowInstance, Tab, TabDict, TabManager
from .types import _T, AsyncResponse, LayerShellConfig, SingleInstanceData, WindowSystemMouseEvent, ac
from .types import AsyncResponse, LayerShellConfig, SingleInstanceData, WindowSystemMouseEvent, ac
from .typing_compat import PopenType, TypedDict
from .utils import (
cleanup_ssh_control_masters,
@ -3399,7 +3399,7 @@ class Boss:
target_tab.make_active()
return target_tab
def choose_entry(
def choose_entry[_T](
self, title: str, entries: Iterable[tuple[_T | str | None, str]],
callback: Callable[[_T | str | None], None],
subtitle: str = '',

View file

@ -14,10 +14,9 @@ from kitty.conf.types import Definition, MultiOption, Option, ParserFuncType, un
from kitty.fast_data_types import NULL_COLOR_VALUE
from kitty.options.utils import parse_options_for_map
from kitty.simple_cli_definitions import serialize_as_go_string
from kitty.types import _T
def chunks(lst: list[_T], n: int) -> Iterator[list[_T]]:
def chunks[_T](lst: list[_T], n: int) -> Iterator[list[_T]]:
for i in range(0, len(lst), n):
yield lst[i:i + n]

View file

@ -25,7 +25,6 @@ from kitty.fast_data_types import (
)
from kitty.options.types import Options, defaults
from kitty.options.utils import parse_font_spec
from kitty.types import _T
from kitty.typing_compat import CoreTextFont, FontConfigPattern
from kitty.utils import log_error
@ -53,7 +52,7 @@ def font_for_family(family: str) -> tuple[FontObject, bool, bool]:
return font_for_family_fontconfig(family)
def merge_ranges(
def merge_ranges[_T](
a: tuple[tuple[int, int], _T], b: tuple[tuple[int, int], _T], priority_map: dict[tuple[int, int], int]
) -> Generator[tuple[tuple[int, int], _T], None, None]:
a_start, a_end = a[0]
@ -119,7 +118,7 @@ def merge_ranges(
yield from ranges
def coalesce_symbol_maps(maps: dict[tuple[int, int], _T]) -> dict[tuple[int, int], _T]:
def coalesce_symbol_maps[_T](maps: dict[tuple[int, int], _T]) -> dict[tuple[int, int], _T]:
if not maps:
return maps
priority_map = {r: i for i, r in enumerate(maps.keys())}

View file

@ -9,8 +9,6 @@ from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypedDict, TypeVar,
if TYPE_CHECKING:
from kitty.fast_data_types import SingleKey
_T = TypeVar('_T')
class SingleInstanceData(TypedDict):
cmd: str
@ -188,7 +186,7 @@ class RunOnce[T]:
self._override = sentinel
def run_once(f: Callable[[], _T]) -> 'RunOnce[_T]':
def run_once[T](f: Callable[[], T]) -> RunOnce[T]:
return RunOnce(f)
@ -219,7 +217,7 @@ class ActionSpec(NamedTuple):
doc: str
def ac(group: ActionGroup, doc: str) -> Callable[[_T], _T]:
def ac[_T](group: ActionGroup, doc: str) -> Callable[[_T], _T]:
def w(f: _T) -> _T:
setattr(f, 'action_spec', ActionSpec(group, doc))
return f