Add type hints.
David Blume

David Blume commited on 2020-12-30 22:43:33
Showing 1 changed files, with 6 additions and 5 deletions.

... ...
@@ -17,9 +17,10 @@ from argparse import ArgumentParser
17 17
 import subprocess
18 18
 import shutil
19 19
 import filecmp
20
+from typing import Optional, List
20 21
 
21 22
 
22
-def call(cmd_array, changelist, preview):
23
+def call(cmd_array: List[str], changelist: str, preview: bool) -> int:
23 24
     """ If not preview, makes the call."""
24 25
     ret = 0
25 26
     if not preview:
... ...
@@ -31,7 +32,7 @@ def call(cmd_array, changelist, preview):
31 32
     return ret
32 33
 
33 34
 
34
-def add_changelist_to_cmd(cmd, changelist):
35
+def add_changelist_to_cmd(cmd: List[str], changelist: Optional[str]) -> List[str]:
35 36
     """Injects "-c changelist" to the p4 command."""
36 37
     if changelist is None:
37 38
         return cmd
... ...
@@ -40,12 +41,12 @@ def add_changelist_to_cmd(cmd, changelist):
40 41
     return cmd
41 42
 
42 43
 
43
-def do_diff_by_name(preview, changelist, source_dir, p4_dir):
44
+def do_diff_by_name(preview: bool, changelist: str, source_dir: str, p4_dir: str) -> None:
44 45
     do_diff(preview, changelist, filecmp.dircmp(p4_dir, source_dir))
45 46
     delete_empty_directories(p4_dir)
46 47
 
47 48
 
48
-def delete_empty_directories(top):
49
+def delete_empty_directories(top: str) -> None:
49 50
     """ p4 deletes could leave us with empty hierarchies. """
50 51
     for root, dirs, files in os.walk(top, topdown=False):
51 52
         for name in dirs:
... ...
@@ -55,7 +56,7 @@ def delete_empty_directories(top):
55 56
                 pass
56 57
 
57 58
 
58
-def do_diff(preview, changelist, d):
59
+def do_diff(preview: bool, changelist:str, d: filecmp.dircmp) -> None:
59 60
     for f in d.right_only:
60 61
         if os.path.isfile(os.path.join(d.right, f)):
61 62
             if not preview:
62 63