mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-26 21:08:59 +08:00
Unify allowlist handling (#11889)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Ali Hamdan <ali.hamdan.dev@gmail.com>
This commit is contained in:
@@ -6,19 +6,21 @@ Note that therefore the output of stubtest depends on which Python version it is
|
||||
In typeshed CI, we run stubtest with each currently supported Python minor version.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from utils import allowlist_stubtest_arguments, allowlists_path
|
||||
|
||||
|
||||
def run_stubtest(typeshed_dir: Path) -> int:
|
||||
allowlist_dir = typeshed_dir / "tests" / "stubtest_allowlists"
|
||||
version_allowlist = f"py{sys.version_info.major}{sys.version_info.minor}.txt"
|
||||
platform_allowlist = f"{sys.platform}.txt"
|
||||
combined_allowlist = f"{sys.platform}-py{sys.version_info.major}{sys.version_info.minor}.txt"
|
||||
local_version_allowlist = version_allowlist + ".local"
|
||||
extra_allowlists = [version_allowlist, combined_allowlist, local_version_allowlist]
|
||||
|
||||
# Note when stubtest imports distutils, it will likely actually import setuptools._distutils
|
||||
# This is fine because we don't care about distutils and allowlist all errors from it
|
||||
@@ -31,17 +33,8 @@ def run_stubtest(typeshed_dir: Path) -> int:
|
||||
"--check-typeshed",
|
||||
"--custom-typeshed-dir",
|
||||
str(typeshed_dir),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / "py3_common.txt"),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / version_allowlist),
|
||||
*allowlist_stubtest_arguments("stdlib", extra_allowlists),
|
||||
]
|
||||
if (allowlist_dir / platform_allowlist).exists():
|
||||
cmd += ["--allowlist", str(allowlist_dir / platform_allowlist)]
|
||||
if (allowlist_dir / combined_allowlist).exists():
|
||||
cmd += ["--allowlist", str(allowlist_dir / combined_allowlist)]
|
||||
if (allowlist_dir / local_version_allowlist).exists():
|
||||
cmd += ["--allowlist", str(allowlist_dir / local_version_allowlist)]
|
||||
if sys.version_info < (3, 10):
|
||||
# As discussed in https://github.com/python/typeshed/issues/3693, we only aim for
|
||||
# positional-only arg accuracy for python 3.10 and above.
|
||||
@@ -58,7 +51,10 @@ def run_stubtest(typeshed_dir: Path) -> int:
|
||||
file=sys.stderr,
|
||||
)
|
||||
print("\n\n", file=sys.stderr)
|
||||
print(f'To fix "unused allowlist" errors, remove the corresponding entries from {allowlist_dir}', file=sys.stderr)
|
||||
print(
|
||||
f'To fix "unused allowlist" errors, remove the corresponding entries from {allowlists_path("stdlib")}',
|
||||
file=sys.stderr,
|
||||
)
|
||||
return e.returncode
|
||||
else:
|
||||
print("stubtest succeeded", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user