@@ -56,6 +56,18 @@ def __new__(cls, *args, **kwargs):
56
56
raise ValueError (f"{ dep } has no attribute { inst ._required_attribute } " )
57
57
return inst
58
58
59
+ def _tune_down (self ):
60
+ return None
61
+
62
+ def _tune_up (self , parent ):
63
+ return None
64
+
65
+ def _cull_down (self ):
66
+ return None
67
+
68
+ def _cull_up (self , parent ):
69
+ return None
70
+
59
71
@property
60
72
def _required_attribute (self ) -> str :
61
73
# Specify if the first `dependency` must support
@@ -226,28 +238,26 @@ def rewrite(self, kind: str):
226
238
_continue = False
227
239
228
240
# Rewrite this node
229
- if down_name in expr .__dir__ ():
230
- out = getattr (expr , down_name )()
241
+ out = getattr (expr , down_name )()
242
+ if out is None :
243
+ out = expr
244
+ if not isinstance (out , Expr ):
245
+ return out
246
+ if out ._name != expr ._name :
247
+ expr = out
248
+ continue
249
+
250
+ # Allow children to rewrite their parents
251
+ for child in expr .dependencies ():
252
+ out = getattr (child , up_name )(expr )
231
253
if out is None :
232
254
out = expr
233
255
if not isinstance (out , Expr ):
234
256
return out
235
- if out ._name != expr ._name :
257
+ if out is not expr and out ._name != expr ._name :
236
258
expr = out
237
- continue
238
-
239
- # Allow children to rewrite their parents
240
- for child in expr .dependencies ():
241
- if up_name in child .__dir__ ():
242
- out = getattr (child , up_name )(expr )
243
- if out is None :
244
- out = expr
245
- if not isinstance (out , Expr ):
246
- return out
247
- if out is not expr and out ._name != expr ._name :
248
- expr = out
249
- _continue = True
250
- break
259
+ _continue = True
260
+ break
251
261
252
262
if _continue :
253
263
continue
0 commit comments