diff options
author | Alberto Bertogli <albertito@blitiri.com.ar> | 2020-05-24 15:20:56 +0200 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2020-05-24 17:04:24 +0200 |
commit | 20b99ee568fd15ca2897f995e9775861ef293544 (patch) | |
tree | 4d1ad17d066f2e05a7927245136b78188d32f79e /git-arr | |
parent | ad950208bf19d49e8f825007ba267ca3c43b8390 (diff) | |
download | git-arr-fork-20b99ee568fd15ca2897f995e9775861ef293544.zip |
Introduce type annotations
This patch introduces type annotations, which can be checked with mypy.
The coverage is not very comprehensive for now, but it is a starting
point and will be expanded in later patches.
Diffstat (limited to 'git-arr')
-rwxr-xr-x | git-arr | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9,8 +9,9 @@ import optparse import os import re import sys +from typing import Union -import bottle +import bottle # type: ignore import git import utils @@ -328,10 +329,10 @@ def is_404(e): return e.status_code == 404 -def generate(output, only=None): +def generate(output: str, only=None): """Generate static html to the output directory.""" - def write_to(path, func_or_str, args=(), mtime=None): + def write_to(path: str, func_or_str, args=(), mtime=None): path = output + "/" + path dirname = os.path.dirname(path) @@ -339,7 +340,7 @@ def generate(output, only=None): os.makedirs(dirname) if mtime: - path_mtime = 0 + path_mtime: Union[float, int] = 0 if os.path.exists(path): path_mtime = os.stat(path).st_mtime @@ -380,8 +381,8 @@ def generate(output, only=None): print(from_path, "->", to_path) os.symlink(to_path, from_path) - def write_tree(r, bn, mtime): - t = r.tree(bn) + def write_tree(r: git.Repo, bn: str, mtime): + t: git.Tree = r.tree(bn) write_to("r/%s/b/%s/t/index.html" % (r.name, bn), tree, (r, bn), mtime) |