mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-15 13:04:38 +02:00
Make latest version of ty happy
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import inspect
|
||||
from typing import NamedTuple, cast
|
||||
from typing import Any, NamedTuple
|
||||
|
||||
from .boss import Boss
|
||||
from .tabs import Tab
|
||||
@@ -39,18 +39,19 @@ def get_all_actions() -> dict[ActionGroup, list[Action]]:
|
||||
|
||||
ans: dict[ActionGroup, list[Action]] = {}
|
||||
|
||||
def is_action(x: object) -> bool:
|
||||
def is_action(x: Any) -> bool:
|
||||
return isinstance(getattr(x, 'action_spec', None), ActionSpec)
|
||||
|
||||
def as_action(x: object) -> Action:
|
||||
def as_action(x: Any) -> Action:
|
||||
spec: ActionSpec = getattr(x, 'action_spec')
|
||||
doc = inspect.cleandoc(spec.doc)
|
||||
lines = doc.splitlines()
|
||||
first = lines.pop(0)
|
||||
short_help = first
|
||||
long_help = '\n'.join(lines).strip()
|
||||
assert spec.group in groups
|
||||
return Action(getattr(x, '__name__'), cast(ActionGroup, spec.group), short_help, long_help)
|
||||
if spec.group not in groups:
|
||||
raise KeyError(f'Unknown action type: {spec.group}')
|
||||
return Action(getattr(x, '__name__'), spec.group, short_help, long_help)
|
||||
|
||||
seen = set()
|
||||
for cls in (Window, Tab, Boss):
|
||||
|
||||
@@ -7,7 +7,7 @@ import posixpath
|
||||
import shlex
|
||||
from collections.abc import Iterable, Iterator
|
||||
from contextlib import suppress
|
||||
from typing import Any, NamedTuple, cast
|
||||
from typing import Any, NamedTuple
|
||||
from urllib.parse import ParseResult, unquote, urlparse
|
||||
|
||||
from .conf.utils import KeyAction, to_cmdline_implementation
|
||||
@@ -56,7 +56,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]:
|
||||
elif key in ('mime', 'ext', 'protocol', 'file', 'path', 'url', 'fragment_matches'):
|
||||
if key != 'url':
|
||||
rest = rest.lower()
|
||||
match_criteria.append(MatchCriteria(cast(MatchType, key), rest))
|
||||
match_criteria.append(MatchCriteria(key, rest))
|
||||
elif key == 'action_alias':
|
||||
try:
|
||||
alias_name, alias_val = rest.split(maxsplit=1)
|
||||
|
||||
Reference in New Issue
Block a user