@@ -51,7 +51,6 @@ def python_version(arg: str) -> tuple[MajorVersion, MinorVersion]:
51
51
52
52
class CommandLineArgs (argparse .Namespace ):
53
53
verbose : int
54
- dry_run : bool
55
54
exclude : list [str ] | None
56
55
python_version : list [tuple [MajorVersion , MinorVersion ]] | None
57
56
dir : list [Directory ] | None
@@ -61,7 +60,6 @@ class CommandLineArgs(argparse.Namespace):
61
60
62
61
parser = argparse .ArgumentParser (description = "Test runner for typeshed. Patterns are unanchored regexps on the full path." )
63
62
parser .add_argument ("-v" , "--verbose" , action = "count" , default = 0 , help = "More output" )
64
- parser .add_argument ("-n" , "--dry-run" , action = "store_true" , help = "Don't actually run mypy" )
65
63
parser .add_argument ("-x" , "--exclude" , type = str , nargs = "*" , help = "Exclude pattern" )
66
64
parser .add_argument (
67
65
"-p" , "--python-version" , type = python_version , nargs = "*" , action = "extend" , help = "These versions only (major[.minor])"
@@ -89,7 +87,6 @@ class TestConfig:
89
87
"""Configuration settings for a single run of the `test_typeshed` function."""
90
88
91
89
verbose : int
92
- dry_run : bool
93
90
exclude : list [str ] | None
94
91
major : MajorVersion
95
92
minor : MinorVersion
@@ -230,27 +227,24 @@ def run_mypy(args: TestConfig, configurations: list[MypyDistConf], files: list[s
230
227
mypy_args = [* flags , * files ]
231
228
if args .verbose :
232
229
print ("running mypy" , " " .join (mypy_args ))
233
- if args .dry_run :
234
- exit_code = 0
230
+ stdout_redirect , stderr_redirect = StringIO (), StringIO ()
231
+ with redirect_stdout (stdout_redirect ), redirect_stderr (stderr_redirect ):
232
+ returned_stdout , returned_stderr , exit_code = mypy_run (mypy_args )
233
+
234
+ if exit_code :
235
+ print_error ("failure\n " )
236
+ captured_stdout = stdout_redirect .getvalue ()
237
+ captured_stderr = stderr_redirect .getvalue ()
238
+ if returned_stderr :
239
+ print_error (returned_stderr )
240
+ if captured_stderr :
241
+ print_error (captured_stderr )
242
+ if returned_stdout :
243
+ print_error (returned_stdout )
244
+ if captured_stdout :
245
+ print_error (captured_stdout , end = "" )
235
246
else :
236
- stdout_redirect , stderr_redirect = StringIO (), StringIO ()
237
- with redirect_stdout (stdout_redirect ), redirect_stderr (stderr_redirect ):
238
- returned_stdout , returned_stderr , exit_code = mypy_run (mypy_args )
239
-
240
- if exit_code :
241
- print_error ("failure\n " )
242
- captured_stdout = stdout_redirect .getvalue ()
243
- captured_stderr = stderr_redirect .getvalue ()
244
- if returned_stderr :
245
- print_error (returned_stderr )
246
- if captured_stderr :
247
- print_error (captured_stderr )
248
- if returned_stdout :
249
- print_error (returned_stdout )
250
- if captured_stdout :
251
- print_error (captured_stdout , end = "" )
252
- else :
253
- print_success_msg ()
247
+ print_success_msg ()
254
248
return exit_code
255
249
256
250
@@ -405,14 +399,11 @@ def test_the_test_cases(code: int, args: TestConfig) -> TestResults:
405
399
flags = get_mypy_flags (args , None , strict = True , enforce_error_codes = False )
406
400
print (f"Running mypy on the test_cases directory ({ num_test_case_files } files)..." )
407
401
print ("Running mypy " + " " .join (flags ))
408
- if args .dry_run :
409
- this_code = 0
410
- else :
411
- # --warn-unused-ignores doesn't work for files inside typeshed.
412
- # SO, to work around this, we copy the test_cases directory into a TemporaryDirectory.
413
- with tempfile .TemporaryDirectory () as td :
414
- shutil .copytree (Path ("test_cases" ), Path (td ) / "test_cases" )
415
- this_code = run_mypy_as_subprocess (td , flags )
402
+ # --warn-unused-ignores doesn't work for files inside typeshed.
403
+ # SO, to work around this, we copy the test_cases directory into a TemporaryDirectory.
404
+ with tempfile .TemporaryDirectory () as td :
405
+ shutil .copytree (Path ("test_cases" ), Path (td ) / "test_cases" )
406
+ this_code = run_mypy_as_subprocess (td , flags )
416
407
if not this_code :
417
408
print_success_msg ()
418
409
code = max (code , this_code )
@@ -450,7 +441,6 @@ def main() -> None:
450
441
for (major , minor ), platform in product (versions , platforms ):
451
442
config = TestConfig (
452
443
verbose = args .verbose ,
453
- dry_run = args .dry_run ,
454
444
exclude = args .exclude ,
455
445
major = major ,
456
446
minor = minor ,
0 commit comments