mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 01:08:10 +02:00
Add more type annotations
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from typing import Any, Dict, Iterable, Sequence, Tuple, Union
|
||||
from typing import Any, Dict, Iterable, Tuple, Union
|
||||
|
||||
from kitty.conf.utils import KittensKeyDefinition, key_func, parse_kittens_key
|
||||
from kitty.conf.utils import (
|
||||
KeyFuncWrapper, KittensKeyDefinition, parse_kittens_key
|
||||
)
|
||||
|
||||
func_with_args, args_funcs = key_func()
|
||||
FuncArgsType = Tuple[str, Sequence[Any]]
|
||||
ReturnType = Tuple[str, Any]
|
||||
func_with_args = KeyFuncWrapper[ReturnType]()
|
||||
|
||||
|
||||
@func_with_args('scroll_by')
|
||||
@@ -57,6 +59,6 @@ def syntax_aliases(raw: str) -> Dict[str, str]:
|
||||
|
||||
|
||||
def parse_map(val: str) -> Iterable[KittensKeyDefinition]:
|
||||
x = parse_kittens_key(val, args_funcs)
|
||||
x = parse_kittens_key(val, func_with_args.args_funcs)
|
||||
if x is not None:
|
||||
yield x
|
||||
|
||||
@@ -447,7 +447,7 @@ def process_single_item(
|
||||
item: Union[bytes, str],
|
||||
args: IcatCLIOptions,
|
||||
parsed_opts: ParsedOpts,
|
||||
url_pat: Optional[Pattern] = None,
|
||||
url_pat: Optional['Pattern[str]'] = None,
|
||||
maybe_dir: bool = True
|
||||
) -> None:
|
||||
is_tempfile = False
|
||||
|
||||
@@ -169,7 +169,7 @@ def get_result(name: str) -> Optional[str]:
|
||||
return q.get_result(get_options())
|
||||
|
||||
|
||||
def do_queries(queries: Iterable, cli_opts: QueryTerminalCLIOptions) -> Dict[str, str]:
|
||||
def do_queries(queries: Iterable[str], cli_opts: QueryTerminalCLIOptions) -> Dict[str, str]:
|
||||
actions = tuple(all_queries[x]() for x in queries)
|
||||
qstring = ''.join(a.query_code() for a in actions)
|
||||
received = b''
|
||||
|
||||
@@ -149,7 +149,7 @@ def theme_name_from_file_name(fname: str) -> str:
|
||||
ans = fname.rsplit('.', 1)[0]
|
||||
ans = ans.replace('_', ' ')
|
||||
|
||||
def camel_case(m: Match) -> str:
|
||||
def camel_case(m: 'Match[str]') -> str:
|
||||
return str(m.group(1) + ' ' + m.group(2))
|
||||
|
||||
ans = re.sub(r'([a-z])([A-Z])', camel_case, ans)
|
||||
|
||||
Reference in New Issue
Block a user