6
6
In typeshed CI, we run stubtest with each currently supported Python minor version.
7
7
8
8
"""
9
+
9
10
from __future__ import annotations
10
11
11
12
import subprocess
12
13
import sys
13
14
from pathlib import Path
14
15
16
+ from utils import allowlist_stubtest_arguments , allowlists_path
17
+
15
18
16
19
def run_stubtest (typeshed_dir : Path ) -> int :
17
- allowlist_dir = typeshed_dir / "tests" / "stubtest_allowlists"
18
20
version_allowlist = f"py{ sys .version_info .major } { sys .version_info .minor } .txt"
19
- platform_allowlist = f"{ sys .platform } .txt"
20
21
combined_allowlist = f"{ sys .platform } -py{ sys .version_info .major } { sys .version_info .minor } .txt"
21
22
local_version_allowlist = version_allowlist + ".local"
23
+ extra_allowlists = [version_allowlist , combined_allowlist , local_version_allowlist ]
22
24
23
25
# Note when stubtest imports distutils, it will likely actually import setuptools._distutils
24
26
# 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:
31
33
"--check-typeshed" ,
32
34
"--custom-typeshed-dir" ,
33
35
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 ),
38
37
]
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 )]
45
38
if sys .version_info < (3 , 10 ):
46
39
# As discussed in https://github.com/python/typeshed/issues/3693, we only aim for
47
40
# positional-only arg accuracy for python 3.10 and above.
@@ -58,7 +51,10 @@ def run_stubtest(typeshed_dir: Path) -> int:
58
51
file = sys .stderr ,
59
52
)
60
53
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
+ )
62
58
return e .returncode
63
59
else :
64
60
print ("stubtest succeeded" , file = sys .stderr )
0 commit comments