Skip to content

Commit 3cb6f5b

Browse files
author
Guido van Rossum
committed
Print nicer error when type_info.json not found
Fixes #68
1 parent 5efbc5d commit 3cb6f5b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyannotate_tools/annotations/__main__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import logging
66
import os
7+
import sys
78

89
from lib2to3.main import StdoutRefactoringTool
910

@@ -78,6 +79,10 @@ def main(args_override=None):
7879
args = parser.parse_args(args_override)
7980
if not args.files and not args.dump:
8081
parser.error("At least one file/directory is required")
82+
try:
83+
open(args.type_info).close()
84+
except OSError as err:
85+
sys.exit("Can't open type info file: %s" % err)
8186

8287
# Set up logging handler.
8388
level = logging.DEBUG if args.verbose else logging.INFO
@@ -88,8 +93,7 @@ def main(args_override=None):
8893
return
8994

9095
# Run pass 2 with output into a variable.
91-
infile = args.type_info
92-
data = generate_annotations_json_string(infile) # type: List[Any]
96+
data = generate_annotations_json_string(args.type_info) # type: List[Any]
9397

9498
# Run pass 3 with input from that variable.
9599
if args.auto_any:

0 commit comments

Comments
 (0)