Add types to pre-commit

This commit is contained in:
Anthony Sottile 2020-01-10 23:32:28 -08:00
parent fa536a8693
commit 327ed924a3
62 changed files with 911 additions and 411 deletions

View file

@ -1,6 +1,8 @@
import argparse
import os.path
import tarfile
from typing import Optional
from typing import Sequence
from pre_commit import output
from pre_commit.util import cmd_output_b
@ -23,7 +25,7 @@ REPOS = (
)
def make_archive(name, repo, ref, destdir):
def make_archive(name: str, repo: str, ref: str, destdir: str) -> str:
"""Makes an archive of a repository in the given destdir.
:param text name: Name to give the archive. For instance foo. The file
@ -49,7 +51,7 @@ def make_archive(name, repo, ref, destdir):
return output_path
def main(argv=None):
def main(argv: Optional[Sequence[str]] = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('--dest', default='pre_commit/resources')
args = parser.parse_args(argv)
@ -58,6 +60,7 @@ def main(argv=None):
f'Making {archive_name}.tar.gz for {repo}@{ref}',
)
make_archive(archive_name, repo, ref, args.dest)
return 0
if __name__ == '__main__':