@@ -156,19 +156,24 @@ def __init__(
156
156
157
157
@property
158
158
def data (self ):
159
- return self .result ()
160
-
161
- def __repr__ (self ):
162
- return self .result ().__repr__ ()
163
-
164
- def result (self ) -> ApplyOutputT :
165
159
if self ._done :
166
160
return self ._data
167
161
v = self .x .result ()
168
162
self ._data = self .f (v )
169
163
self ._done = True
170
164
return self ._data
171
165
166
+ def __repr__ (self ):
167
+ return self .result ().__repr__ ()
168
+
169
+ def result (self ) -> ApplyOutputT :
170
+ data = self .data
171
+ if isinstance (data , PdlLazy ):
172
+ result = data .result ()
173
+ else :
174
+ result = data
175
+ return result # pyright: ignore
176
+
172
177
173
178
LazyApplyInputT = TypeVar ("LazyApplyInputT" )
174
179
LazyApplyOutputT = TypeVar ("LazyApplyOutputT" )
@@ -192,20 +197,14 @@ def __init__(
192
197
x1 : PdlLazy [Apply2Input1T ],
193
198
x2 : PdlLazy [Apply2Input2T ],
194
199
):
195
- self ._data : Apply2OutputT
200
+ self ._data : Apply2OutputT | PdlLazy [ Apply2OutputT ]
196
201
self .f = f
197
202
self .x1 = x1
198
203
self .x2 = x2
199
204
self ._done = False
200
205
201
206
@property
202
- def data (self ):
203
- return self .result ()
204
-
205
- def __repr__ (self ):
206
- return self .result ().__repr__ ()
207
-
208
- def result (self ) -> Apply2OutputT :
207
+ def data (self ) -> Apply2OutputT | PdlLazy [Apply2OutputT ]:
209
208
if self ._done :
210
209
return self ._data
211
210
if isinstance (self .x1 , PdlLazy ):
@@ -220,6 +219,17 @@ def result(self) -> Apply2OutputT:
220
219
self ._done = True
221
220
return self ._data
222
221
222
+ def __repr__ (self ):
223
+ return self .result ().__repr__ ()
224
+
225
+ def result (self ) -> Apply2OutputT :
226
+ data = self .data
227
+ if isinstance (data , PdlLazy ):
228
+ result = data .result ()
229
+ else :
230
+ result = data
231
+ return result # pyright: ignore
232
+
223
233
224
234
LazyApply2Input1T = TypeVar ("LazyApply2Input1T" ) # pylint: disable=invalid-name
225
235
LazyApply2Input2T = TypeVar ("LazyApply2Input2T" ) # pylint: disable=invalid-name
0 commit comments