mypy_test.py: Always add dependencies of stubs to the files to test (#8800)

This commit is contained in:
Alex Waygood
2022-10-04 08:05:13 -07:00
committed by GitHub
parent e5d52a39d4
commit 5da171ba45
4 changed files with 30 additions and 18 deletions

View File

@@ -1,8 +1,11 @@
"""Utilities that are imported by multiple scripts in the tests directory."""
from __future__ import annotations
import os
import re
from functools import cache
from itertools import filterfalse
from pathlib import Path
from typing import NamedTuple
@@ -53,6 +56,13 @@ def read_dependencies(distribution: str) -> tuple[str, ...]:
return tuple(dependencies)
def get_recursive_requirements(package_name: str, seen: set[str] | None = None) -> list[str]:
seen = seen if seen is not None else {package_name}
for dependency in filterfalse(seen.__contains__, read_dependencies(package_name)):
seen.update(get_recursive_requirements(dependency, seen))
return sorted(seen | {package_name})
# ====================================================================
# Parsing the stdlib/VERSIONS file
# ====================================================================