From e285e52e1385a3c63a850dd5a2e8b2c744d7293a Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sat, 1 Jun 2024 18:51:57 +0200 Subject: [PATCH] `mypy_test.py`: warn about incompatible python version only on tested files (#12079) --- tests/mypy_test.py | 30 +++++++++++++++--------------- tests/regr_test.py | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 925478978..cafaca811 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -527,26 +527,26 @@ def test_third_party_stubs(args: TestConfig, tempdir: Path) -> TestSummary: if spec_matches_path(gitignore_spec, distribution_path): continue - metadata = read_metadata(distribution) - if not metadata.requires_python.contains(PYTHON_VERSION): - msg = ( - f"skipping {distribution!r} (requires Python {metadata.requires_python}; " - f"test is being run using Python {PYTHON_VERSION})" - ) - print(colored(msg, "yellow")) - summary.skip_package() - continue - if not metadata.requires_python.contains(args.version): - msg = f"skipping {distribution!r} for target Python {args.version} (requires Python {metadata.requires_python})" - print(colored(msg, "yellow")) - summary.skip_package() - continue - if ( distribution_path in args.filter or Path("stubs") in args.filter or any(distribution_path in path.parents for path in args.filter) ): + metadata = read_metadata(distribution) + if not metadata.requires_python.contains(PYTHON_VERSION): + msg = ( + f"skipping {distribution!r} (requires Python {metadata.requires_python}; " + f"test is being run using Python {PYTHON_VERSION})" + ) + print(colored(msg, "yellow")) + summary.skip_package() + continue + if not metadata.requires_python.contains(args.version): + msg = f"skipping {distribution!r} for target Python {args.version} (requires Python {metadata.requires_python})" + print(colored(msg, "yellow")) + summary.skip_package() + continue + distributions_to_check[distribution] = get_recursive_requirements(distribution) # Setup the necessary virtual environments for testing the third-party stubs. diff --git a/tests/regr_test.py b/tests/regr_test.py index f8a3601ec..c8fc9e912 100755 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -292,14 +292,14 @@ def concurrently_run_testcases( for testcase_dir, tempdir in packageinfo_to_tempdir.items(): pkg = testcase_dir.name requires_python = None - if not testcase_dir.is_stdlib: # type: ignore[misc] # mypy bug, already fixed on master + if not testcase_dir.is_stdlib: requires_python = read_metadata(pkg).requires_python if not requires_python.contains(PYTHON_VERSION): msg = f"skipping {pkg!r} (requires Python {requires_python}; test is being run using Python {PYTHON_VERSION})" print(colored(msg, "yellow")) continue for version in versions_to_test: - if not testcase_dir.is_stdlib: # type: ignore[misc] # mypy bug, already fixed on master + if not testcase_dir.is_stdlib: assert requires_python is not None if not requires_python.contains(version): msg = f"skipping {pkg!r} for target Python {version} (requires Python {requires_python})"