From 4e3f0e9e78cc3db6516e7d3bcf949cd56cdda5ca Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Thu, 24 Oct 2024 14:13:11 -0700 Subject: [PATCH 1/3] allow the use of --show-traceback and --pdb with stubtest Both are advertized by internal error handling that can occur while running stubtest. This makes it possible to follow the directions given. --- mypy/stubtest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 0de5411b01de..88e667722433 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -1938,6 +1938,10 @@ def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int: options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir) options.config_file = args.mypy_config_file options.use_builtins_fixtures = use_builtins_fixtures + if args.show_traceback: + options.show_traceback = True + if args.pdb: + options.pdb = True if options.config_file: @@ -2091,6 +2095,10 @@ def parse_options(args: list[str]) -> _Arguments: parser.add_argument( "--version", action="version", version="%(prog)s " + mypy.version.__version__ ) + parser.add_argument("--pdb", action="store_true", help="Invoke pdb on fatal error") + parser.add_argument( + "--show-traceback", "--tb", action="store_true", help="Show traceback on fatal error" + ) return parser.parse_args(args, namespace=_Arguments()) From 7c9ac251faf1621d4d726481c58aebd7021398bb Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Thu, 24 Oct 2024 14:20:44 -0700 Subject: [PATCH 2/3] don't need the conditional --- mypy/stubtest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 88e667722433..c4bcacceb420 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -1938,10 +1938,8 @@ def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int: options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir) options.config_file = args.mypy_config_file options.use_builtins_fixtures = use_builtins_fixtures - if args.show_traceback: - options.show_traceback = True - if args.pdb: - options.pdb = True + options.show_traceback = args.show_traceback + options.pdb = args.pdb if options.config_file: From d48b50348c38166647544a31f2c5b542c6e0b01f Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Thu, 24 Oct 2024 14:23:27 -0700 Subject: [PATCH 3/3] update _Arguments class to match --- mypy/stubtest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index c4bcacceb420..36cd0a213d4d 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -1893,6 +1893,8 @@ class _Arguments: custom_typeshed_dir: str | None check_typeshed: bool version: str + show_traceback: bool + pdb: bool # typeshed added a stub for __main__, but that causes stubtest to check itself