##// END OF EJS Templates
typing: add type hints to pycompat.maplist()...
Matt Harbison -
r51070:0ab92dab default
parent child Browse files
Show More
@@ -32,6 +32,7 b' from typing import ('
32 Any,
32 Any,
33 AnyStr,
33 AnyStr,
34 BinaryIO,
34 BinaryIO,
35 Callable,
35 Dict,
36 Dict,
36 Iterable,
37 Iterable,
37 Iterator,
38 Iterator,
@@ -58,6 +59,8 b' if not globals(): # hide this from non-'
58
59
59 _GetOptResult = Tuple[List[Tuple[bytes, bytes]], List[bytes]]
60 _GetOptResult = Tuple[List[Tuple[bytes, bytes]], List[bytes]]
60 _T0 = TypeVar('_T0')
61 _T0 = TypeVar('_T0')
62 _T1 = TypeVar('_T1')
63 _S = TypeVar('_S')
61 _Tbytestr = TypeVar('_Tbytestr', bound='bytestr')
64 _Tbytestr = TypeVar('_Tbytestr', bound='bytestr')
62
65
63
66
@@ -129,8 +132,21 b' sysplatform: bytes = sys.platform.encode'
129 sysexecutable: bytes = os.fsencode(sys.executable) if sys.executable else b''
132 sysexecutable: bytes = os.fsencode(sys.executable) if sys.executable else b''
130
133
131
134
132 def maplist(*args):
135 if TYPE_CHECKING:
133 return list(map(*args))
136
137 @overload
138 def maplist(f: Callable[[_T0], _S], arg: Iterable[_T0]) -> List[_S]:
139 ...
140
141 @overload
142 def maplist(
143 f: Callable[[_T0, _T1], _S], arg1: Iterable[_T0], arg2: Iterable[_T1]
144 ) -> List[_S]:
145 ...
146
147
148 def maplist(f, *args):
149 return list(map(f, *args))
134
150
135
151
136 def rangelist(*args):
152 def rangelist(*args):
General Comments 0
You need to be logged in to leave comments. Login now