diff --git a/src/cwhy/cwhy.py b/src/cwhy/cwhy.py index aa35002..3457841 100755 --- a/src/cwhy/cwhy.py +++ b/src/cwhy/cwhy.py @@ -21,7 +21,7 @@ from .print_debug import dprint, enable_debug_printing -def print_key_info(): +def print_key_info() -> None: dprint("You need a key (or keys) from an AI service to use CWhy.") dprint() dprint("OpenAI:") diff --git a/src/cwhy/print_debug.py b/src/cwhy/print_debug.py index 58a557b..7056437 100644 --- a/src/cwhy/print_debug.py +++ b/src/cwhy/print_debug.py @@ -5,7 +5,10 @@ _INFO_WIDTH = 30 -def dprint(*objects, sep=" ", end="\n", file=None, flush=False): +def dprint( + *objects, sep: str = " ", end: str = "\n", file=None, flush: bool = False +) -> None: + global _debug if not _debug: return print(*objects, sep=sep, end=end, file=file, flush=flush) @@ -25,6 +28,6 @@ def dprint(*objects, sep=" ", end="\n", file=None, flush=False): print(info, line, file=file, flush=flush) -def enable_debug_printing(): +def enable_debug_printing() -> None: global _debug _debug = True diff --git a/tests/anonymizer.py b/tests/anonymizer.py index 6467c95..9530714 100755 --- a/tests/anonymizer.py +++ b/tests/anonymizer.py @@ -2,9 +2,10 @@ import argparse import tempfile +from typing import Tuple -def anonymize(path): +def anonymize(path: str) -> Tuple[str, str]: with open(path) as file: content = file.read() diff --git a/tests/apply_diff.py b/tests/apply_diff.py index 5613463..4241a50 100755 --- a/tests/apply_diff.py +++ b/tests/apply_diff.py @@ -4,7 +4,7 @@ import sys -def apply(data): +def apply(data) -> None: # Sort modifications by reverse start line number to apply them in that order. data["modifications"].sort(key=lambda m: m["start-line-number"], reverse=True) diff --git a/tests/prepare.py b/tests/prepare.py index 440c373..e0a5c75 100644 --- a/tests/prepare.py +++ b/tests/prepare.py @@ -7,7 +7,7 @@ ROOT = os.path.dirname(os.path.abspath(__file__)) -def prepare(language): +def prepare(language) -> None: try: with open(os.path.join(ROOT, language, "manifest.yml"), "r") as stream: manifest = yaml.load(stream, yaml.Loader) @@ -26,11 +26,11 @@ def prepare(language): subprocess.run(command, shell=True).check_returncode() -def prepare_all(): +def prepare_all() -> None: for directory in os.listdir(ROOT): if os.path.isdir(os.path.join(ROOT, directory)): prepare(directory) -def clean(): +def clean() -> None: shutil.rmtree(os.path.join(ROOT, "_deps"), ignore_errors=True) diff --git a/tests/regression.py b/tests/regression.py index b26d02f..3e434e0 100644 --- a/tests/regression.py +++ b/tests/regression.py @@ -10,7 +10,7 @@ ROOT = os.path.dirname(os.path.abspath(__file__)) -def get_cwhy_prompt(invocation): +def get_cwhy_prompt(invocation) -> str: process = subprocess.run( f"cwhy --show-prompt --- {invocation}", text=True, @@ -28,7 +28,7 @@ def get_cwhy_prompt(invocation): return stdout -def main(args): +def main(args) -> None: prepare.clean() prepare.prepare_all()