From 837f7e0ed4f87869f314ec102c0d6e47ec3272ec Mon Sep 17 00:00:00 2001 From: Sam Xifaras Date: Sun, 11 Feb 2024 04:04:28 -0500 Subject: [PATCH] stubtest: correct type annotations in _Arguments (#16897) Two fields in the `_Arguments` class, `mypy_config_file` and `custom_typeshed_dir`, can take on a None value, but they are not marked as such. Calling `stubtest.parse_options` on an empty list of arguments reproduces the situation where these two fields are None. --- mypy/stubtest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index c2f82c98d089..dd43c472d67f 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -1878,8 +1878,8 @@ class _Arguments: allowlist: list[str] generate_allowlist: bool ignore_unused_allowlist: bool - mypy_config_file: str - custom_typeshed_dir: str + mypy_config_file: str | None + custom_typeshed_dir: str | None check_typeshed: bool version: str @@ -1922,7 +1922,7 @@ def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int: options.incremental = False options.custom_typeshed_dir = args.custom_typeshed_dir if options.custom_typeshed_dir: - options.abs_custom_typeshed_dir = os.path.abspath(args.custom_typeshed_dir) + 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