mypy_test.py: warn about incompatible python version only on tested files (#12079)

This commit is contained in:
Ali Hamdan
2024-06-01 18:51:57 +02:00
committed by GitHub
parent b019e98116
commit e285e52e13
2 changed files with 17 additions and 17 deletions

View File

@@ -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.

View File

@@ -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})"