mypy_test: Exclude sub-modules not in current Py version (#12352)

This commit is contained in:
Sebastian Rittau
2024-07-16 16:04:54 +02:00
committed by GitHub
parent 274b10da70
commit cc40120ee5
2 changed files with 43 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ import sys
from collections.abc import Iterable, Mapping
from functools import lru_cache
from pathlib import Path
from typing import Any, Final, NamedTuple, Tuple
from typing import Any, Dict, Final, NamedTuple, Tuple
from typing_extensions import TypeAlias
import pathspec
@@ -108,14 +108,14 @@ def get_mypy_req() -> str:
# ====================================================================
VersionTuple: TypeAlias = Tuple[int, int]
SupportedVersionsDict: TypeAlias = Dict[str, Tuple[VersionTuple, VersionTuple]]
VERSIONS_PATH = STDLIB_PATH / "VERSIONS"
VERSION_LINE_RE = re.compile(r"^([a-zA-Z_][a-zA-Z0-9_.]*): ([23]\.\d{1,2})-([23]\.\d{1,2})?$")
VERSION_RE = re.compile(r"^([23])\.(\d+)$")
def parse_stdlib_versions_file() -> dict[str, tuple[VersionTuple, VersionTuple]]:
def parse_stdlib_versions_file() -> SupportedVersionsDict:
result: dict[str, tuple[VersionTuple, VersionTuple]] = {}
with VERSIONS_PATH.open(encoding="UTF-8") as f:
for line in f: