66In typeshed CI, we run stubtest with each currently supported Python minor version.
77
88"""
9+
910from __future__ import annotations
1011
1112import subprocess
1213import sys
1314from pathlib import Path
1415
16+ from utils import allowlist_stubtest_arguments , allowlists_path
17+
1518
1619def run_stubtest (typeshed_dir : Path ) -> int :
17- allowlist_dir = typeshed_dir / "tests" / "stubtest_allowlists"
1820 version_allowlist = f"py{ sys .version_info .major } { sys .version_info .minor } .txt"
19- platform_allowlist = f"{ sys .platform } .txt"
2021 combined_allowlist = f"{ sys .platform } -py{ sys .version_info .major } { sys .version_info .minor } .txt"
2122 local_version_allowlist = version_allowlist + ".local"
23+ extra_allowlists = [version_allowlist , combined_allowlist , local_version_allowlist ]
2224
2325 # Note when stubtest imports distutils, it will likely actually import setuptools._distutils
2426 # 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:
3133 "--check-typeshed" ,
3234 "--custom-typeshed-dir" ,
3335 str (typeshed_dir ),
34- "--allowlist" ,
35- str (allowlist_dir / "py3_common.txt" ),
36- "--allowlist" ,
37- str (allowlist_dir / version_allowlist ),
36+ * allowlist_stubtest_arguments ("stdlib" , extra_allowlists ),
3837 ]
39- if (allowlist_dir / platform_allowlist ).exists ():
40- cmd += ["--allowlist" , str (allowlist_dir / platform_allowlist )]
41- if (allowlist_dir / combined_allowlist ).exists ():
42- cmd += ["--allowlist" , str (allowlist_dir / combined_allowlist )]
43- if (allowlist_dir / local_version_allowlist ).exists ():
44- cmd += ["--allowlist" , str (allowlist_dir / local_version_allowlist )]
4538 if sys .version_info < (3 , 10 ):
4639 # As discussed in https://github.com/python/typeshed/issues/3693, we only aim for
4740 # positional-only arg accuracy for python 3.10 and above.
@@ -58,7 +51,10 @@ def run_stubtest(typeshed_dir: Path) -> int:
5851 file = sys .stderr ,
5952 )
6053 print ("\n \n " , file = sys .stderr )
61- print (f'To fix "unused allowlist" errors, remove the corresponding entries from { allowlist_dir } ' , file = sys .stderr )
54+ print (
55+ f'To fix "unused allowlist" errors, remove the corresponding entries from { allowlists_path ("stdlib" )} ' ,
56+ file = sys .stderr ,
57+ )
6258 return e .returncode
6359 else :
6460 print ("stubtest succeeded" , file = sys .stderr )
0 commit comments