diff --git a/docs/conf.py b/docs/conf.py index 888172ef3..f1be8ed47 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -170,7 +170,9 @@ texinfo_documents = [ # GitHub linking inline roles {{{ -def num_role(which: str, name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]: +def num_role( + which: str, name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = [] +) -> Tuple[List[nodes.reference], List[nodes.problematic]]: ' Link to a github issue ' try: issue_num = int(text) @@ -188,7 +190,9 @@ def num_role(which: str, name: str, rawtext: str, text: str, lineno: int, inline return [node], [] -def commit_role(name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]: +def commit_role( + name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = [] +) -> Tuple[List[nodes.reference], List[nodes.problematic]]: ' Link to a github commit ' try: commit_id = subprocess.check_output( @@ -264,7 +268,7 @@ def write_remote_control_protocol_docs() -> None: # {{{ ) field_pat = re.compile(r'\s*([a-zA-Z0-9_+]+)\s*:\s*(.+)') - def format_cmd(p: Callable, name: str, cmd: RemoteCommand) -> None: + def format_cmd(p: Callable[..., None], name: str, cmd: RemoteCommand) -> None: p(name) p('-' * 80) lines = (cmd.__doc__ or '').strip().splitlines() @@ -304,7 +308,7 @@ def write_remote_control_protocol_docs() -> None: # {{{ # config file docs {{{ -class ConfLexer(RegexLexer): +class ConfLexer(RegexLexer): # type: ignore name = 'Conf' aliases = ['conf'] filenames = ['*.conf'] @@ -343,7 +347,7 @@ class ConfLexer(RegexLexer): } -class SessionLexer(RegexLexer): +class SessionLexer(RegexLexer): # type: ignore name = 'Session' aliases = ['session'] filenames = ['*.session'] @@ -359,7 +363,9 @@ class SessionLexer(RegexLexer): } -def link_role(name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]: +def link_role( + name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = [] +) -> Tuple[List[nodes.reference], List[nodes.problematic]]: text = text.replace('\n', ' ') m = re.match(r'(.+)\s+<(.+?)>', text) if m is None: @@ -376,7 +382,7 @@ def link_role(name: str, rawtext: str, text: str, lineno: int, inliner: Any, opt def expand_opt_references(conf_name: str, text: str) -> str: conf_name += '.' - def expand(m: Match) -> str: + def expand(m: Match[str]) -> str: ref = m.group(1) if '<' not in ref and '.' not in ref: full_ref = conf_name + ref diff --git a/gen-wcwidth.py b/gen-wcwidth.py index ca098f8ad..3a4a8a208 100755 --- a/gen-wcwidth.py +++ b/gen-wcwidth.py @@ -251,7 +251,7 @@ def get_ranges(items: List[int]) -> Generator[Union[int, Tuple[int, int]], None, yield a, b -def write_case(spec: Union[Tuple, int], p: Callable) -> None: +def write_case(spec: Union[Tuple[int, ...], int], p: Callable[..., None]) -> None: if isinstance(spec, tuple): p('\t\tcase 0x{:x} ... 0x{:x}:'.format(*spec)) else: @@ -259,7 +259,7 @@ def write_case(spec: Union[Tuple, int], p: Callable) -> None: @contextmanager -def create_header(path: str, include_data_types: bool = True) -> Generator[Callable, None, None]: +def create_header(path: str, include_data_types: bool = True) -> Generator[Callable[..., None], None, None]: with open(path, 'w') as f: p = partial(print, file=f) p('// unicode data, built from the unicode standard on:', date.today()) @@ -299,7 +299,7 @@ def gen_emoji() -> None: def category_test( name: str, - p: Callable, + p: Callable[..., None], classes: Iterable[str], comment: str, use_static: bool = False, @@ -329,7 +329,7 @@ def category_test( p('\treturn false;\n}\n') -def codepoint_to_mark_map(p: Callable, mark_map: List[int]) -> Dict[int, int]: +def codepoint_to_mark_map(p: Callable[..., None], mark_map: List[int]) -> Dict[int, int]: p('\tswitch(c) { // {{{') rmap = {c: m for m, c in enumerate(mark_map)} for spec in get_ranges(mark_map): @@ -522,7 +522,7 @@ def gen_names() -> None: def gen_wcwidth() -> None: seen: Set[int] = set() - def add(p: Callable, comment: str, chars_: Union[Set[int], FrozenSet[int]], ret: int) -> None: + def add(p: Callable[..., None], comment: str, chars_: Union[Set[int], FrozenSet[int]], ret: int) -> None: chars = chars_ - seen seen.update(chars) p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{' '{') diff --git a/kittens/diff/diff_speedup.pyi b/kittens/diff/diff_speedup.pyi index 9a7a0927d..09069db54 100644 --- a/kittens/diff/diff_speedup.pyi +++ b/kittens/diff/diff_speedup.pyi @@ -4,9 +4,9 @@ from .collect import Segment def split_with_highlights( - line: str, truncate_points: List[int], fg_highlights: List, + line: str, truncate_points: List[int], fg_highlights: List[Segment], bg_highlight: Optional[Segment] -) -> List: +) -> List[str]: pass diff --git a/kittens/diff/render.py b/kittens/diff/render.py index 08f7cfe26..5b29b0f71 100644 --- a/kittens/diff/render.py +++ b/kittens/diff/render.py @@ -209,7 +209,7 @@ def truncate_points(line: str, width: int) -> Generator[int, None, None]: break -def split_with_highlights(line: str, width: int, highlights: List, bg_highlight: Optional[Segment] = None) -> List: +def split_with_highlights(line: str, width: int, highlights: List[Segment], bg_highlight: Optional[Segment] = None) -> List[str]: truncate_pts = list(truncate_points(line, width)) return _split_with_highlights(line, truncate_pts, highlights, bg_highlight) @@ -270,7 +270,7 @@ def hunk_title(hunk_num: int, hunk: Hunk, margin_size: int, available_cols: int) def render_half_line( line_number: int, line: str, - highlights: List, + highlights: List[Segment], ltype: str, margin_size: int, available_cols: int, diff --git a/kitty/types.py b/kitty/types.py index c9f489e6b..c6da783c2 100644 --- a/kitty/types.py +++ b/kitty/types.py @@ -107,7 +107,7 @@ else: self._override = RunOnce -def run_once(f: Callable[[], _T]) -> RunOnce[_T]: +def run_once(f: Callable[[], _T]) -> 'RunOnce[_T]': return RunOnce(f)