Coverage for src/remedapy/pipe.py: 100%

1 from collections.abc import Callable

2 from typing import Any, TypeVar, overload

3

4 A = TypeVar('A')

5 B = TypeVar('B')

6 C = TypeVar('C')

7 D = TypeVar('D')

8 E = TypeVar('E')

9 F = TypeVar('F')

10 G = TypeVar('G')

11 H = TypeVar('H')

12 I = TypeVar('I')

13 J = TypeVar('J')

14 K = TypeVar('K')

15 L = TypeVar('L')

16 M = TypeVar('M')

17 N = TypeVar('N')

18 O = TypeVar('O')

19 P = TypeVar('P')

20

21

22@overload

23 def pipe(data: A, funcA: Callable[[A], B], /) -> B: ...

24

25

26@overload

27 def pipe(data: A, funcA: Callable[[A], B], funcB: Callable[[B], C], /) -> C: ...

28

29

30@overload

31 def pipe(data: A, funcA: Callable[[A], B], funcB: Callable[[B], C], funcC: Callable[[C], D], /) -> D: ...

32

33

34@overload

35 def pipe(

36 data: A,

37 funcA: Callable[[A], B],

38 funcB: Callable[[B], C],

39 funcC: Callable[[C], D],

40 funcD: Callable[[D], E],

41 /,

42) -> E: ...

43

44

45@overload

46 def pipe(

47 data: A,

48 funcA: Callable[[A], B],

49 funcB: Callable[[B], C],

50 funcC: Callable[[C], D],

51 funcD: Callable[[D], E],

52 funcE: Callable[[E], F],

53 /,

54) -> F: ...

55

56

57@overload

58 def pipe(

59 data: A,

60 funcA: Callable[[A], B],

61 funcB: Callable[[B], C],

62 funcC: Callable[[C], D],

63 funcD: Callable[[D], E],

64 funcE: Callable[[E], F],

65 funcF: Callable[[F], G],

66 /,

67) -> G: ...

68

69

70@overload

71 def pipe(

72 data: A,

73 funcA: Callable[[A], B],

74 funcB: Callable[[B], C],

75 funcC: Callable[[C], D],

76 funcD: Callable[[D], E],

77 funcE: Callable[[E], F],

78 funcF: Callable[[F], G],

79 funcG: Callable[[G], H],

80 /,

81) -> H: ...

82

83

84@overload

85 def pipe(

86 data: A,

87 funcA: Callable[[A], B],

88 funcB: Callable[[B], C],

89 funcC: Callable[[C], D],

90 funcD: Callable[[D], E],

91 funcE: Callable[[E], F],

92 funcF: Callable[[F], G],

93 funcG: Callable[[G], H],

94 funcH: Callable[[H], I],

95 /,

96) -> I: ...

97

98

99@overload

100 def pipe(

101 data: A,

102 funcA: Callable[[A], B],

103 funcB: Callable[[B], C],

104 funcC: Callable[[C], D],

105 funcD: Callable[[D], E],

106 funcE: Callable[[E], F],

107 funcF: Callable[[F], G],

108 funcG: Callable[[G], H],

109 funcH: Callable[[H], I],

110 funcI: Callable[[I], J],

111 /,

112) -> J: ...

113

114

115@overload

116 def pipe(

117 data: A,

118 funcA: Callable[[A], B],

119 funcB: Callable[[B], C],

120 funcC: Callable[[C], D],

121 funcD: Callable[[D], E],

122 funcE: Callable[[E], F],

123 funcF: Callable[[F], G],

124 funcG: Callable[[G], H],

125 funcH: Callable[[H], I],

126 funcI: Callable[[I], J],

127 funcJ: Callable[[J], K],

128 /,

129) -> K: ...

130

131

132@overload

133 def pipe(

134 data: A,

135 funcA: Callable[[A], B],

136 funcB: Callable[[B], C],

137 funcC: Callable[[C], D],

138 funcD: Callable[[D], E],

139 funcE: Callable[[E], F],

140 funcF: Callable[[F], G],

141 funcG: Callable[[G], H],

142 funcH: Callable[[H], I],

143 funcI: Callable[[I], J],

144 funcJ: Callable[[J], K],

145 funcK: Callable[[K], L],

146 /,

147) -> L: ...

148

149

150@overload

151 def pipe(

152 data: A,

153 funcA: Callable[[A], B],

154 funcB: Callable[[B], C],

155 funcC: Callable[[C], D],

156 funcD: Callable[[D], E],

157 funcE: Callable[[E], F],

158 funcF: Callable[[F], G],

159 funcG: Callable[[G], H],

160 funcH: Callable[[H], I],

161 funcI: Callable[[I], J],

162 funcJ: Callable[[J], K],

163 funcK: Callable[[K], L],

164 funcL: Callable[[L], M],

165 /,

166) -> M: ...

167

168

169@overload

170 def pipe(

171 data: A,

172 funcA: Callable[[A], B],

173 funcB: Callable[[B], C],

174 funcC: Callable[[C], D],

175 funcD: Callable[[D], E],

176 funcE: Callable[[E], F],

177 funcF: Callable[[F], G],

178 funcG: Callable[[G], H],

179 funcH: Callable[[H], I],

180 funcI: Callable[[I], J],

181 funcJ: Callable[[J], K],

182 funcK: Callable[[K], L],

183 funcL: Callable[[L], M],

184 funcM: Callable[[M], N],

185 /,

186) -> N: ...

187

188

189@overload

190 def pipe(

191 data: A,

192 funcA: Callable[[A], B],

193 funcB: Callable[[B], C],

194 funcC: Callable[[C], D],

195 funcD: Callable[[D], E],

196 funcE: Callable[[E], F],

197 funcF: Callable[[F], G],

198 funcG: Callable[[G], H],

199 funcH: Callable[[H], I],

200 funcI: Callable[[I], J],

201 funcJ: Callable[[J], K],

202 funcK: Callable[[K], L],

203 funcL: Callable[[L], M],

204 funcM: Callable[[M], N],

205 funcN: Callable[[N], O],

206 /,

207) -> O: ...

208

209

210@overload

211 def pipe(

212 data: A,

213 funcA: Callable[[A], B],

214 funcB: Callable[[B], C],

215 funcC: Callable[[C], D],

216 funcD: Callable[[D], E],

217 funcE: Callable[[E], F],

218 funcF: Callable[[F], G],

219 funcG: Callable[[G], H],

220 funcH: Callable[[H], I],

221 funcI: Callable[[I], J],

222 funcJ: Callable[[J], K],

223 funcK: Callable[[K], L],

224 funcL: Callable[[L], M],

225 funcM: Callable[[M], N],

226 funcN: Callable[[N], O],

227 funcO: Callable[[O], P],

228 /,

229) -> P: ...

230

231

232 def pipe(*args: Any) -> Any:

233 x = args[0]

234 for fn in args[1:]:

235 x = fn(x)

236 return x