Apply typing to all of pre-commit-hooks
diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py
index e35a65c..90aef03 100644
--- a/pre_commit_hooks/mixed_line_ending.py
+++ b/pre_commit_hooks/mixed_line_ending.py
@@ -4,6 +4,9 @@
import argparse
import collections
+from typing import Dict
+from typing import Optional
+from typing import Sequence
CRLF = b'\r\n'
@@ -14,7 +17,7 @@
FIX_TO_LINE_ENDING = {'cr': CR, 'crlf': CRLF, 'lf': LF}
-def _fix(filename, contents, ending):
+def _fix(filename, contents, ending): # type: (str, bytes, bytes) -> None
new_contents = b''.join(
line.rstrip(b'\r\n') + ending for line in contents.splitlines(True)
)
@@ -22,11 +25,11 @@
f.write(new_contents)
-def fix_filename(filename, fix):
+def fix_filename(filename, fix): # type: (str, str) -> int
with open(filename, 'rb') as f:
contents = f.read()
- counts = collections.defaultdict(int)
+ counts = collections.defaultdict(int) # type: Dict[bytes, int]
for line in contents.splitlines(True):
for ending in ALL_ENDINGS:
@@ -63,7 +66,7 @@
return other_endings
-def main(argv=None):
+def main(argv=None): # type: (Optional[Sequence[str]]) -> int
parser = argparse.ArgumentParser()
parser.add_argument(
'-f', '--fix',