From 38bc0ec0e65e4103b64c9666d993375cce08bd9b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 20 Aug 2022 21:32:17 +0100 Subject: [PATCH] `mypy_test.py`: simplify argument parsing (#8577) --- tests/mypy_test.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 30559844e..5a4e97ab1 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -46,18 +46,6 @@ def python_version(arg: str) -> tuple[MajorVersion, MinorVersion]: return version # type: ignore[return-value] -def python_platform(platform: str) -> str: - if platform not in SUPPORTED_PLATFORMS: - raise ValueError - return platform - - -def typeshed_directory(directory: str) -> str: - if directory not in TYPESHED_DIRECTORIES: - raise ValueError - return directory - - class CommandLineArgs(argparse.Namespace): verbose: int dry_run: bool @@ -78,14 +66,14 @@ parser.add_argument( parser.add_argument( "-d", "--dir", - type=typeshed_directory, + choices=TYPESHED_DIRECTORIES, nargs="*", action="extend", help="Test only these top-level typeshed directories (defaults to all typeshed directories)", ) parser.add_argument( "--platform", - type=python_platform, + choices=SUPPORTED_PLATFORMS, nargs="*", action="extend", help="Run mypy for certain OS platforms (defaults to sys.platform only)",