Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e285e52

Browse files
authored
mypy_test.py: warn about incompatible python version only on tested files (#12079)
1 parent b019e98 commit e285e52

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

tests/mypy_test.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -527,26 +527,26 @@ def test_third_party_stubs(args: TestConfig, tempdir: Path) -> TestSummary:
527527
if spec_matches_path(gitignore_spec, distribution_path):
528528
continue
529529

530-
metadata = read_metadata(distribution)
531-
if not metadata.requires_python.contains(PYTHON_VERSION):
532-
msg = (
533-
f"skipping {distribution!r} (requires Python {metadata.requires_python}; "
534-
f"test is being run using Python {PYTHON_VERSION})"
535-
)
536-
print(colored(msg, "yellow"))
537-
summary.skip_package()
538-
continue
539-
if not metadata.requires_python.contains(args.version):
540-
msg = f"skipping {distribution!r} for target Python {args.version} (requires Python {metadata.requires_python})"
541-
print(colored(msg, "yellow"))
542-
summary.skip_package()
543-
continue
544-
545530
if (
546531
distribution_path in args.filter
547532
or Path("stubs") in args.filter
548533
or any(distribution_path in path.parents for path in args.filter)
549534
):
535+
metadata = read_metadata(distribution)
536+
if not metadata.requires_python.contains(PYTHON_VERSION):
537+
msg = (
538+
f"skipping {distribution!r} (requires Python {metadata.requires_python}; "
539+
f"test is being run using Python {PYTHON_VERSION})"
540+
)
541+
print(colored(msg, "yellow"))
542+
summary.skip_package()
543+
continue
544+
if not metadata.requires_python.contains(args.version):
545+
msg = f"skipping {distribution!r} for target Python {args.version} (requires Python {metadata.requires_python})"
546+
print(colored(msg, "yellow"))
547+
summary.skip_package()
548+
continue
549+
550550
distributions_to_check[distribution] = get_recursive_requirements(distribution)
551551

552552
# Setup the necessary virtual environments for testing the third-party stubs.

tests/regr_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,14 @@ def concurrently_run_testcases(
292292
for testcase_dir, tempdir in packageinfo_to_tempdir.items():
293293
pkg = testcase_dir.name
294294
requires_python = None
295-
if not testcase_dir.is_stdlib: # type: ignore[misc] # mypy bug, already fixed on master
295+
if not testcase_dir.is_stdlib:
296296
requires_python = read_metadata(pkg).requires_python
297297
if not requires_python.contains(PYTHON_VERSION):
298298
msg = f"skipping {pkg!r} (requires Python {requires_python}; test is being run using Python {PYTHON_VERSION})"
299299
print(colored(msg, "yellow"))
300300
continue
301301
for version in versions_to_test:
302-
if not testcase_dir.is_stdlib: # type: ignore[misc] # mypy bug, already fixed on master
302+
if not testcase_dir.is_stdlib:
303303
assert requires_python is not None
304304
if not requires_python.contains(version):
305305
msg = f"skipping {pkg!r} for target Python {version} (requires Python {requires_python})"

0 commit comments

Comments
 (0)