Skip to content

Commit cffe452

Browse files
committed
added type hints, tox config
1 parent 8f22dcc commit cffe452

File tree

4 files changed

+120
-83
lines changed

4 files changed

+120
-83
lines changed

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ exclude=tests
2424
[options.entry_points]
2525
console_scripts =
2626
tm-diff = tmDiff.__main__:main
27+
28+
[mypy]
29+
30+
[mypy-tmTable.*]
31+
ignore_missing_imports = True

tmDiff/__main__.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
import argparse
22
import os
33
import sys
4+
from typing import Callable, Dict, List
45

56
from . import menudiff
67
from . import __version__
78

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] = {
2728
FMT_UNIFIED: menudiff.unified_diff,
2829
FMT_CONTEXT: menudiff.context_diff,
2930
FMT_HTML: menudiff.html_diff,
3031
FMT_REPORT: menudiff.report_diff,
3132
}
3233

3334

34-
def parse_args():
35+
def parse_args() -> argparse.Namespace:
3536
parser = argparse.ArgumentParser()
3637
parser.add_argument("file",
3738
nargs=2,
@@ -78,13 +79,13 @@ def parse_args():
7879
return parser.parse_args()
7980

8081

81-
def main():
82+
def main() -> int:
8283
args = parse_args()
8384

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]
8687

87-
skip = []
88+
skip: List[str] = []
8889

8990
# Skip module specific attributes
9091
if SKIP_MODULE in args.skip:

0 commit comments

Comments
 (0)