Add more type annotations
This commit is contained in:
parent
9c2f96f7eb
commit
6f19fd5912
20
docs/conf.py
20
docs/conf.py
@ -170,7 +170,9 @@ texinfo_documents = [
|
|||||||
|
|
||||||
# GitHub linking inline roles {{{
|
# 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 '
|
' Link to a github issue '
|
||||||
try:
|
try:
|
||||||
issue_num = int(text)
|
issue_num = int(text)
|
||||||
@ -188,7 +190,9 @@ def num_role(which: str, name: str, rawtext: str, text: str, lineno: int, inline
|
|||||||
return [node], []
|
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 '
|
' Link to a github commit '
|
||||||
try:
|
try:
|
||||||
commit_id = subprocess.check_output(
|
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*(.+)')
|
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(name)
|
||||||
p('-' * 80)
|
p('-' * 80)
|
||||||
lines = (cmd.__doc__ or '').strip().splitlines()
|
lines = (cmd.__doc__ or '').strip().splitlines()
|
||||||
@ -304,7 +308,7 @@ def write_remote_control_protocol_docs() -> None: # {{{
|
|||||||
|
|
||||||
# config file docs {{{
|
# config file docs {{{
|
||||||
|
|
||||||
class ConfLexer(RegexLexer):
|
class ConfLexer(RegexLexer): # type: ignore
|
||||||
name = 'Conf'
|
name = 'Conf'
|
||||||
aliases = ['conf']
|
aliases = ['conf']
|
||||||
filenames = ['*.conf']
|
filenames = ['*.conf']
|
||||||
@ -343,7 +347,7 @@ class ConfLexer(RegexLexer):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SessionLexer(RegexLexer):
|
class SessionLexer(RegexLexer): # type: ignore
|
||||||
name = 'Session'
|
name = 'Session'
|
||||||
aliases = ['session']
|
aliases = ['session']
|
||||||
filenames = ['*.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', ' ')
|
text = text.replace('\n', ' ')
|
||||||
m = re.match(r'(.+)\s+<(.+?)>', text)
|
m = re.match(r'(.+)\s+<(.+?)>', text)
|
||||||
if m is None:
|
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:
|
def expand_opt_references(conf_name: str, text: str) -> str:
|
||||||
conf_name += '.'
|
conf_name += '.'
|
||||||
|
|
||||||
def expand(m: Match) -> str:
|
def expand(m: Match[str]) -> str:
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
if '<' not in ref and '.' not in ref:
|
if '<' not in ref and '.' not in ref:
|
||||||
full_ref = conf_name + ref
|
full_ref = conf_name + ref
|
||||||
|
|||||||
@ -251,7 +251,7 @@ def get_ranges(items: List[int]) -> Generator[Union[int, Tuple[int, int]], None,
|
|||||||
yield a, b
|
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):
|
if isinstance(spec, tuple):
|
||||||
p('\t\tcase 0x{:x} ... 0x{:x}:'.format(*spec))
|
p('\t\tcase 0x{:x} ... 0x{:x}:'.format(*spec))
|
||||||
else:
|
else:
|
||||||
@ -259,7 +259,7 @@ def write_case(spec: Union[Tuple, int], p: Callable) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@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:
|
with open(path, 'w') as f:
|
||||||
p = partial(print, file=f)
|
p = partial(print, file=f)
|
||||||
p('// unicode data, built from the unicode standard on:', date.today())
|
p('// unicode data, built from the unicode standard on:', date.today())
|
||||||
@ -299,7 +299,7 @@ def gen_emoji() -> None:
|
|||||||
|
|
||||||
def category_test(
|
def category_test(
|
||||||
name: str,
|
name: str,
|
||||||
p: Callable,
|
p: Callable[..., None],
|
||||||
classes: Iterable[str],
|
classes: Iterable[str],
|
||||||
comment: str,
|
comment: str,
|
||||||
use_static: bool = False,
|
use_static: bool = False,
|
||||||
@ -329,7 +329,7 @@ def category_test(
|
|||||||
p('\treturn false;\n}\n')
|
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) { // {{{')
|
p('\tswitch(c) { // {{{')
|
||||||
rmap = {c: m for m, c in enumerate(mark_map)}
|
rmap = {c: m for m, c in enumerate(mark_map)}
|
||||||
for spec in get_ranges(mark_map):
|
for spec in get_ranges(mark_map):
|
||||||
@ -522,7 +522,7 @@ def gen_names() -> None:
|
|||||||
def gen_wcwidth() -> None:
|
def gen_wcwidth() -> None:
|
||||||
seen: Set[int] = set()
|
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
|
chars = chars_ - seen
|
||||||
seen.update(chars)
|
seen.update(chars)
|
||||||
p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
|
p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
|
||||||
|
|||||||
@ -4,9 +4,9 @@ from .collect import Segment
|
|||||||
|
|
||||||
|
|
||||||
def split_with_highlights(
|
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]
|
bg_highlight: Optional[Segment]
|
||||||
) -> List:
|
) -> List[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -209,7 +209,7 @@ def truncate_points(line: str, width: int) -> Generator[int, None, None]:
|
|||||||
break
|
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))
|
truncate_pts = list(truncate_points(line, width))
|
||||||
return _split_with_highlights(line, truncate_pts, highlights, bg_highlight)
|
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(
|
def render_half_line(
|
||||||
line_number: int,
|
line_number: int,
|
||||||
line: str,
|
line: str,
|
||||||
highlights: List,
|
highlights: List[Segment],
|
||||||
ltype: str,
|
ltype: str,
|
||||||
margin_size: int,
|
margin_size: int,
|
||||||
available_cols: int,
|
available_cols: int,
|
||||||
|
|||||||
@ -107,7 +107,7 @@ else:
|
|||||||
self._override = RunOnce
|
self._override = RunOnce
|
||||||
|
|
||||||
|
|
||||||
def run_once(f: Callable[[], _T]) -> RunOnce[_T]:
|
def run_once(f: Callable[[], _T]) -> 'RunOnce[_T]':
|
||||||
return RunOnce(f)
|
return RunOnce(f)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user