|
1 | 1 | import argparse |
2 | 2 | import os |
3 | 3 | import sys |
| 4 | +from typing import Callable, Dict, List |
4 | 5 |
|
5 | 6 | from . import menudiff |
6 | 7 | from . import __version__ |
7 | 8 |
|
8 | | -FMT_UNIFIED = "unified" |
9 | | -FMT_CONTEXT = "context" |
10 | | -FMT_HTML = "html" |
11 | | -FMT_REPORT = "report" |
12 | | -FMT_DEFAULT = FMT_UNIFIED |
13 | | -FMT_CHOICES = [FMT_UNIFIED, FMT_CONTEXT, FMT_HTML, FMT_REPORT] |
14 | | - |
15 | | -SKIP_MODULE = "module" |
16 | | -SKIP_COMMENT = "comment" |
17 | | -SKIP_LABELS = "labels" |
18 | | -SKIP_CHOICES = [SKIP_MODULE, SKIP_COMMENT, SKIP_LABELS] |
19 | | - |
20 | | -SORT_INDEX = "index" |
21 | | -SORT_NAME = "name" |
22 | | -SORT_EXPRESSION = "expression" |
23 | | -SORT_DEFAULT = SORT_INDEX |
24 | | -SORT_CHOICES = [SORT_INDEX, SORT_NAME, SORT_EXPRESSION] |
25 | | - |
26 | | -DIFF_FUNCTIONS = { |
| 9 | +FMT_UNIFIED: str = "unified" |
| 10 | +FMT_CONTEXT: str = "context" |
| 11 | +FMT_HTML: str = "html" |
| 12 | +FMT_REPORT: str = "report" |
| 13 | +FMT_DEFAULT: str = FMT_UNIFIED |
| 14 | +FMT_CHOICES: List[str] = [FMT_UNIFIED, FMT_CONTEXT, FMT_HTML, FMT_REPORT] |
| 15 | + |
| 16 | +SKIP_MODULE: str = "module" |
| 17 | +SKIP_COMMENT: str = "comment" |
| 18 | +SKIP_LABELS: str = "labels" |
| 19 | +SKIP_CHOICES: List[str] = [SKIP_MODULE, SKIP_COMMENT, SKIP_LABELS] |
| 20 | + |
| 21 | +SORT_INDEX: str = "index" |
| 22 | +SORT_NAME: str = "name" |
| 23 | +SORT_EXPRESSION: str = "expression" |
| 24 | +SORT_DEFAULT: str = SORT_INDEX |
| 25 | +SORT_CHOICES: List[str] = [SORT_INDEX, SORT_NAME, SORT_EXPRESSION] |
| 26 | + |
| 27 | +DIFF_FUNCTIONS: Dict[str, Callable] = { |
27 | 28 | FMT_UNIFIED: menudiff.unified_diff, |
28 | 29 | FMT_CONTEXT: menudiff.context_diff, |
29 | 30 | FMT_HTML: menudiff.html_diff, |
30 | 31 | FMT_REPORT: menudiff.report_diff, |
31 | 32 | } |
32 | 33 |
|
33 | 34 |
|
34 | | -def parse_args(): |
| 35 | +def parse_args() -> argparse.Namespace: |
35 | 36 | parser = argparse.ArgumentParser() |
36 | 37 | parser.add_argument("file", |
37 | 38 | nargs=2, |
@@ -78,13 +79,13 @@ def parse_args(): |
78 | 79 | return parser.parse_args() |
79 | 80 |
|
80 | 81 |
|
81 | | -def main(): |
| 82 | +def main() -> int: |
82 | 83 | args = parse_args() |
83 | 84 |
|
84 | | - from_file = args.file[0] |
85 | | - to_file = args.file[1] |
| 85 | + from_file: str = args.file[0] |
| 86 | + to_file: str = args.file[1] |
86 | 87 |
|
87 | | - skip = [] |
| 88 | + skip: List[str] = [] |
88 | 89 |
|
89 | 90 | # Skip module specific attributes |
90 | 91 | if SKIP_MODULE in args.skip: |
|
0 commit comments