mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
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:
committed by
Tim Abbott
parent
43ac901ad9
commit
5901e7ba7e
@@ -5,8 +5,7 @@ import argparse
|
||||
import hashlib
|
||||
from typing import Iterable, List, MutableSet
|
||||
|
||||
def expand_reqs_helper(fpath, visited):
|
||||
# type: (str, MutableSet[str]) -> List[str]
|
||||
def expand_reqs_helper(fpath: str, visited: MutableSet[str]) -> List[str]:
|
||||
if fpath in visited:
|
||||
return []
|
||||
else:
|
||||
@@ -27,8 +26,7 @@ def expand_reqs_helper(fpath, visited):
|
||||
result.append(dep)
|
||||
return result
|
||||
|
||||
def expand_reqs(fpath):
|
||||
# type: (str) -> List[str]
|
||||
def expand_reqs(fpath: str) -> List[str]:
|
||||
"""
|
||||
Returns a sorted list of unique dependencies specified by the requirements file `fpath`.
|
||||
Removes comments from the output and recursively visits files specified inside `fpath`.
|
||||
@@ -38,13 +36,11 @@ def expand_reqs(fpath):
|
||||
output = expand_reqs_helper(absfpath, set())
|
||||
return sorted(set(output))
|
||||
|
||||
def hash_deps(deps):
|
||||
# type: (Iterable[str]) -> str
|
||||
def hash_deps(deps: Iterable[str]) -> str:
|
||||
deps_str = "\n".join(deps) + "\n"
|
||||
return hashlib.sha1(deps_str.encode('utf-8')).hexdigest()
|
||||
|
||||
def main():
|
||||
# type: () -> int
|
||||
def main() -> int:
|
||||
description = ("Finds the SHA1 hash of list of dependencies in a requirements file"
|
||||
" after recursively visiting all files specified in it.")
|
||||
parser = argparse.ArgumentParser(description=description)
|
||||
|
||||
Reference in New Issue
Block a user