12
12
import tempfile
13
13
import time
14
14
from collections import defaultdict
15
+ from collections .abc import Sequence
15
16
from dataclasses import dataclass
16
17
from itertools import product
17
18
from pathlib import Path
18
19
from threading import Lock
19
- from typing import TYPE_CHECKING , Any , NamedTuple
20
+ from typing import TYPE_CHECKING , Any , NamedTuple , Tuple
20
21
21
22
if TYPE_CHECKING :
22
23
from _typeshed import StrPath
53
54
54
55
ReturnCode : TypeAlias = int
55
56
VersionString : TypeAlias = Annotated [str , "Must be one of the entries in SUPPORTED_VERSIONS" ]
56
- VersionTuple : TypeAlias = tuple [int , int ]
57
+ VersionTuple : TypeAlias = Tuple [int , int ]
57
58
Platform : TypeAlias = Annotated [str , "Must be one of the entries in SUPPORTED_PLATFORMS" ]
58
59
59
60
@@ -78,6 +79,21 @@ def valid_path(cmd_arg: str) -> Path:
78
79
parser = argparse .ArgumentParser (
79
80
description = "Typecheck typeshed's stubs with mypy. Patterns are unanchored regexps on the full path."
80
81
)
82
+ if sys .version_info < (3 , 8 ):
83
+
84
+ class ExtendAction (argparse .Action ):
85
+ def __call__ (
86
+ self ,
87
+ parser : argparse .ArgumentParser ,
88
+ namespace : argparse .Namespace ,
89
+ values : Sequence [str ],
90
+ option_string : object = None ,
91
+ ) -> None :
92
+ items = getattr (namespace , self .dest ) or []
93
+ items .extend (values )
94
+ setattr (namespace , self .dest , items )
95
+
96
+ parser .register ("action" , "extend" , ExtendAction )
81
97
parser .add_argument (
82
98
"filter" ,
83
99
type = valid_path ,
@@ -324,7 +340,7 @@ def test_third_party_distribution(
324
340
325
341
mypypath = os .pathsep .join (str (Path ("stubs" , dist )) for dist in seen_dists )
326
342
if args .verbose :
327
- print (colored (f"\n { mypypath = } " , "blue" ))
343
+ print (colored (f"\n MYPYPATH= { mypypath } " , "blue" ))
328
344
code = run_mypy (
329
345
args ,
330
346
configurations ,
0 commit comments