Filter pytype tests by stdlib/VERSIONS file (#12649)

Filter the files to run pytype tests on by stdlib/VERSIONS file. This
becomes important for Python 3.12, where e.g. checking asynchat.pyi
requires asyncore.pyi, both of which have been removed in 3.12.
This commit is contained in:
Jan Kühle
2024-09-12 18:40:19 +02:00
committed by GitHub
parent bc6b3b2aba
commit d326c9bd42
3 changed files with 28 additions and 16 deletions

View File

@@ -132,6 +132,14 @@ def parse_stdlib_versions_file() -> SupportedVersionsDict:
return result
def supported_versions_for_module(module_versions: SupportedVersionsDict, module_name: str) -> tuple[VersionTuple, VersionTuple]:
while "." in module_name:
if module_name in module_versions:
return module_versions[module_name]
module_name = ".".join(module_name.split(".")[:-1])
return module_versions[module_name]
def _parse_version(v_str: str) -> tuple[int, int]:
m = VERSION_RE.match(v_str)
assert m, f"invalid version: {v_str}"