From 172809d4e2144dec5025b52a106fe2f571100008 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 15 Oct 2016 22:27:55 -0700 Subject: [PATCH] Annotate the rest of scripts in tools/. --- tools/analyze-url-coverage | 5 +++++ tools/deprecated/iframe-bot/show-last-messages | 3 +++ tools/get-handlebar-vars | 1 + tools/print-all/print-all | 3 +++ tools/webpack | 6 ++++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/analyze-url-coverage b/tools/analyze-url-coverage index cf245b2c9d..4a30071afb 100755 --- a/tools/analyze-url-coverage +++ b/tools/analyze-url-coverage @@ -2,9 +2,11 @@ from __future__ import print_function from collections import defaultdict +from typing import Any, Dict, Iterable import ujson def analyze_url_coverage(): + # type: () -> None fn = 'var/url_coverage.txt' # TODO: make path more robust, maybe use json suffix calls = [] for line in open(fn): @@ -15,6 +17,7 @@ def analyze_url_coverage(): show_which_tests_ran_endpoints(calls) def show_slow_endpoints(calls): + # type: (Iterable[Dict[str, Any]]) -> None tups = [] for call in calls: tups.append((call['delay'], call['url'], call['method'])) @@ -30,6 +33,7 @@ def show_slow_endpoints(calls): print() def show_best_coverage(calls): + # type: (Iterable[Dict[str, Any]]) -> None count = defaultdict(int) # type: Dict[str, int] for call in calls: @@ -46,6 +50,7 @@ def show_best_coverage(calls): print() def show_which_tests_ran_endpoints(calls): + # type: (Iterable[Dict[str, Any]]) -> None test_name_dct = defaultdict(list) # type: Dict[str, List[str]] for call in calls: diff --git a/tools/deprecated/iframe-bot/show-last-messages b/tools/deprecated/iframe-bot/show-last-messages index fb5e0af595..1a7f883834 100755 --- a/tools/deprecated/iframe-bot/show-last-messages +++ b/tools/deprecated/iframe-bot/show-last-messages @@ -15,6 +15,8 @@ import os import optparse import codecs +from typing import IO + usage = """show-last-messages --user= --api-key= --count= Shows the last messages on all public streams. @@ -55,6 +57,7 @@ if result['result'] != 'success': f = codecs.open("output-candidate.html", encoding='utf-8', mode="wb") def uniwrite(f, s): + # type: (IO, str) -> None f.write(s) uniwrite(f, """ diff --git a/tools/get-handlebar-vars b/tools/get-handlebar-vars index b949e5fe33..06af1618fb 100755 --- a/tools/get-handlebar-vars +++ b/tools/get-handlebar-vars @@ -7,6 +7,7 @@ import json from typing import Any, Dict, List def debug(obj): + # type: (Any) -> None print(json.dumps(obj, indent=4)) def parse_file(fn): diff --git a/tools/print-all/print-all b/tools/print-all/print-all index d06312cf12..d6d9ac9587 100755 --- a/tools/print-all/print-all +++ b/tools/print-all/print-all @@ -5,6 +5,8 @@ import os import re import sys +from typing import Iterable + # Prepare a PDF of the entire codebase, ready for printing. # # Depends on: @@ -131,6 +133,7 @@ doc.close() with open('tools/print-all/tex/epilogue.tex', 'w') as f: def print_list(title, xs): + # type: (str, Iterable[str]) -> None f.write('\\section*{%s}\n\n' % (title,)) for x in xs: f.write('%s\n\n' % (x.replace('_', r'\_'),)) diff --git a/tools/webpack b/tools/webpack index 1066347aa9..841979a455 100755 --- a/tools/webpack +++ b/tools/webpack @@ -14,12 +14,14 @@ os.chdir(settings.DEPLOY_ROOT) STATIC_PATH = 'static/' def run(): - # write the file to disk + # type: () -> None + """Builds for production, writing the output to disk""" subprocess.check_call(['tools/node', 'node_modules/.bin/webpack'] + ['--config', 'tools/webpack.production.config.js']) def run_watch(port): - # watch and rebuild on changes, serve file from memory via webpack-dev-server + # type: (str) -> None + """watches and rebuilds on changes, serving files from memory via webpack-dev-server""" subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] + ['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])