4
4
-- The initial line specifies the command line, in the format
5
5
--
6
6
-- # cmd: mypy <options>
7
-
7
+ --
8
+ -- '== Return code: <value>' is added to the output when the process return code
9
+ -- is "nonobvious" -- that is, when it is something other than 0 if there are no
10
+ -- messages and 1 if there are.
8
11
9
12
-- Directories/packages on the command line
10
13
-- ----------------------------------------
@@ -89,6 +92,7 @@ sub.pkg is not a valid Python package name
89
92
# coding: uft-8
90
93
[out]
91
94
mypy: can't decode file 'a.py': unknown encoding: uft-8
95
+ == Return code: 2
92
96
93
97
[case testCannotIgnoreDuplicateModule]
94
98
# cmd: mypy one/mod/__init__.py two/mod/__init__.py
@@ -98,6 +102,7 @@ mypy: can't decode file 'a.py': unknown encoding: uft-8
98
102
# type: ignore
99
103
[out]
100
104
two/mod/__init__.py: error: Duplicate module named 'mod'
105
+ == Return code: 2
101
106
102
107
[case testFlagsFile]
103
108
# cmd: mypy @flagsfile
@@ -225,6 +230,7 @@ x.py:1: error: Function is missing a type annotation
225
230
[file mypy.ini]
226
231
[out]
227
232
mypy.ini: No [mypy] section in config file
233
+ == Return code: 0
228
234
229
235
[case testConfigErrorUnknownFlag]
230
236
# cmd: mypy -c pass
@@ -233,6 +239,7 @@ mypy.ini: No [mypy] section in config file
233
239
bad = 0
234
240
[out]
235
241
mypy.ini: [mypy]: Unrecognized option: bad = 0
242
+ == Return code: 0
236
243
237
244
[case testConfigErrorBadBoolean]
238
245
# cmd: mypy -c pass
@@ -241,6 +248,7 @@ mypy.ini: [mypy]: Unrecognized option: bad = 0
241
248
ignore_missing_imports = nah
242
249
[out]
243
250
mypy.ini: [mypy]: ignore_missing_imports: Not a boolean: nah
251
+ == Return code: 0
244
252
245
253
[case testConfigErrorNotPerFile]
246
254
# cmd: mypy -c pass
@@ -250,6 +258,7 @@ mypy.ini: [mypy]: ignore_missing_imports: Not a boolean: nah
250
258
python_version = 3.4
251
259
[out]
252
260
mypy.ini: [mypy-*]: Per-module sections should only specify per-module flags (python_version)
261
+ == Return code: 0
253
262
254
263
[case testConfigMypyPath]
255
264
# cmd: mypy file.py
@@ -467,6 +476,7 @@ main.py:1: error: Cannot find module named 'a.b'
467
476
python_version = 1.0
468
477
[out]
469
478
mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be 2 or 3)
479
+ == Return code: 0
470
480
471
481
[case testPythonVersionTooOld26]
472
482
# cmd: mypy -c pass
@@ -475,6 +485,7 @@ mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be
475
485
python_version = 2.6
476
486
[out]
477
487
mypy.ini: [mypy]: python_version: Python 2.6 is not supported (must be 2.7)
488
+ == Return code: 0
478
489
479
490
[case testPythonVersionTooOld32]
480
491
# cmd: mypy -c pass
@@ -483,6 +494,7 @@ mypy.ini: [mypy]: python_version: Python 2.6 is not supported (must be 2.7)
483
494
python_version = 3.2
484
495
[out]
485
496
mypy.ini: [mypy]: python_version: Python 3.2 is not supported (must be 3.3 or higher)
497
+ == Return code: 0
486
498
487
499
[case testPythonVersionTooNew28]
488
500
# cmd: mypy -c pass
@@ -491,6 +503,7 @@ mypy.ini: [mypy]: python_version: Python 3.2 is not supported (must be 3.3 or hi
491
503
python_version = 2.8
492
504
[out]
493
505
mypy.ini: [mypy]: python_version: Python 2.8 is not supported (must be 2.7)
506
+ == Return code: 0
494
507
495
508
[case testPythonVersionTooNew40]
496
509
# cmd: mypy -c pass
@@ -499,6 +512,7 @@ mypy.ini: [mypy]: python_version: Python 2.8 is not supported (must be 2.7)
499
512
python_version = 4.0
500
513
[out]
501
514
mypy.ini: [mypy]: python_version: Python major version '4' out of range (must be 2 or 3)
515
+ == Return code: 0
502
516
503
517
[case testPythonVersionAccepted27]
504
518
# cmd: mypy -c pass
@@ -1008,3 +1022,27 @@ def get_tasks(self):
1008
1022
return 'whatever'
1009
1023
[out]
1010
1024
a.py:1: error: Function is missing a type annotation
1025
+
1026
+ [case testMissingFile]
1027
+ # cmd: mypy nope.py
1028
+ [out]
1029
+ mypy: can't read file 'nope.py': No such file or directory
1030
+ == Return code: 2
1031
+
1032 + [case testParseError]
1033
+ # cmd: mypy a.py
1034
+ [file a.py]
1035
+ def foo(
1036
+ [out]
1037
+ a.py:1: error: unexpected EOF while parsing
1038
+ == Return code: 2
1039
+
1040
+ [case testParseErrorAnnots]
1041
+ # cmd: mypy a.py
1042
+ [file a.py]
1043
+ def foo(x):
1044
+ # type: (str, int) -> None
1045
+ return
1046
+ [out]
1047
+ a.py:1: error: Type signature has too many arguments
1048
+ == Return code: 2
0 commit comments