python: Convert function type annotations to Python 3 style.

Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and six fixes for runtime issues:

-    def __init__(self, token: Token, parent: Optional[Node]) -> None:
+    def __init__(self, token: Token, parent: "Optional[Node]") -> None:

-def main(options: argparse.Namespace) -> NoReturn:
+def main(options: argparse.Namespace) -> "NoReturn":

-def fetch_request(url: str, callback: Any, **kwargs: Any) -> Generator[Callable[..., Any], Any, None]:
+def fetch_request(url: str, callback: Any, **kwargs: Any) -> "Generator[Callable[..., Any], Any, None]":

-def assert_server_running(server: subprocess.Popen[bytes], log_file: Optional[str]) -> None:
+def assert_server_running(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> None:

-def server_is_up(server: subprocess.Popen[bytes], log_file: Optional[str]) -> bool:
+def server_is_up(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> bool:

-    method_kwarg_pairs: List[FuncKwargPair],
+    method_kwarg_pairs: "List[FuncKwargPair]",

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-18 18:48:37 -07:00
committed by Tim Abbott
parent 43ac901ad9
commit 5901e7ba7e
68 changed files with 389 additions and 691 deletions

View File

@@ -3,8 +3,7 @@ from typing import Dict, List, Set
from .html_branches import html_branches, HtmlTreeBranch
def show_all_branches(fns):
# type: (List[str]) -> None
def show_all_branches(fns: List[str]) -> None:
for fn in fns:
print(fn)
with open(fn) as f:
@@ -21,8 +20,7 @@ class Grepper:
HtmlTreeBranch objects.
'''
def __init__(self, fns):
# type: (List[str]) -> None
def __init__(self, fns: List[str]) -> None:
all_branches = [] # type: List[HtmlTreeBranch]
for fn in fns:
@@ -38,8 +36,7 @@ class Grepper:
self.all_branches = set(all_branches)
def grep(self, word_set):
# type: (Set[str]) -> None
def grep(self, word_set: Set[str]) -> None:
words = list(word_set) # type: List[str]
@@ -57,7 +54,6 @@ class Grepper:
print(branch.staircase_text())
print('')
def grep(fns, words):
# type: (List[str], Set[str]) -> None
def grep(fns: List[str], words: Set[str]) -> None:
grepper = Grepper(fns)
grepper.grep(words)