@@ -23,7 +23,7 @@ def get_mypy_req() -> str:
23
23
return next (line .strip () for line in f if "mypy" in line )
24
24
25
25
26
- def run_stubtest (dist : Path , * , verbose : bool = False ) -> bool :
26
+ def run_stubtest (dist : Path , * , verbose : bool = False , specified_stubs_only : bool = False ) -> bool :
27
27
with open (dist / "METADATA.toml" , encoding = "UTF-8" ) as f :
28
28
metadata = dict (tomli .loads (f .read ()))
29
29
@@ -36,8 +36,10 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
36
36
37
37
platforms_to_test = stubtest_meta .get ("platforms" , ["linux" ])
38
38
if sys .platform not in platforms_to_test :
39
- print (colored (f"skipping, unsupported platform: { sys .platform } , supported: { platforms_to_test } " , "yellow" ))
40
- return True
39
+ if specified_stubs_only :
40
+ print (colored ("skipping (platform not specified in METADATA.toml)" , "yellow" ))
41
+ return True
42
+ print (colored (f"Note: { dist .name } is not currently tested on { sys .platform } in typeshed's CI." , "yellow" ))
41
43
42
44
with tempfile .TemporaryDirectory () as tmp :
43
45
venv_dir = Path (tmp )
@@ -167,6 +169,11 @@ def main() -> NoReturn:
167
169
parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "verbose output" )
168
170
parser .add_argument ("--num-shards" , type = int , default = 1 )
169
171
parser .add_argument ("--shard-index" , type = int , default = 0 )
172
+ parser .add_argument (
173
+ "--specified-stubs-only" ,
174
+ action = "store_true" ,
175
+ help = "skip the test if the current platform is not specified in METADATA.toml/tool.stubtest.platforms" ,
176
+ )
170
177
parser .add_argument ("dists" , metavar = "DISTRIBUTION" , type = str , nargs = argparse .ZERO_OR_MORE )
171
178
args = parser .parse_args ()
172
179
@@ -180,7 +187,7 @@ def main() -> NoReturn:
180
187
for i , dist in enumerate (dists ):
181
188
if i % args .num_shards != args .shard_index :
182
189
continue
183
- if not run_stubtest (dist , verbose = args .verbose ):
190
+ if not run_stubtest (dist , verbose = args .verbose , specified_stubs_only = args . specified_stubs_only ):
184
191
result = 1
185
192
sys .exit (result )
186
193
0 commit comments