2626__all__ = ["Traversal" ]
2727
2828from zepben .evolve .services .network .tracing .traversal .queue import TraversalQueue
29- from zepben .evolve .util import extra_kwargs_not_allowed
3029
3130T = TypeVar ('T' )
3231U = TypeVar ('U' )
@@ -205,21 +204,20 @@ def create_new_this(self) -> D:
205204 raise NotImplementedError
206205
207206 @singledispatchmethod
208- def add_condition (self , condition : ConditionTypes , ** kwargs ) -> D :
207+ def add_condition (self , condition : ConditionTypes ) -> D :
209208 """
210209 Adds a traversal condition to the traversal.
211210
212211 :param condition: The condition to add.
213- :keyword allow_re_wrapping: Allow rewrapping of :class:`StopConditions` with debug logging
214212
215213 :return: this traversal instance.
216214 """
217215
218216 if callable (condition ): # Callable[[NetworkTraceStep[T], StepContext], None]
219217 if len (inspect .getfullargspec (condition ).args ) == 2 :
220- return self .add_stop_condition (condition , ** kwargs )
218+ return self .add_stop_condition (condition )
221219 elif len (inspect .getfullargspec (condition ).args ) == 4 :
222- return self .add_queue_condition (condition , ** kwargs )
220+ return self .add_queue_condition (condition )
223221 else :
224222 raise RuntimeError (f'Condition does not match expected: Number of args is not 2(Stop Condition) or 4(QueueCondition)' )
225223
@@ -231,30 +229,27 @@ def add_condition(self, condition: ConditionTypes, **kwargs) -> D:
231229
232230 @singledispatchmethod
233231 @add_condition .register (StopCondition )
234- def add_stop_condition (self , condition : StopConditionTypes , ** kwargs ) -> D :
232+ def add_stop_condition (self , condition : StopConditionTypes ) -> D :
235233 """
236234 Adds a stop condition to the traversal. If any stop condition returns
237235 ``True``, the traversal will not call the callback to queue more items
238236 from the current item.
239237
240238 :param condition: The stop condition to add.
241- :keyword allow_re_wrapping: Allow rewrapping of :class:`StopCondition`s with debug logging
242239 :return: this traversal instance.
243240 """
244241
245242 raise RuntimeError (f'Condition [{ condition .__class__ .__name__ } ] does not match expected: [StopCondition | StopConditionWithContextValue | Callable]' )
246243
247244 @add_stop_condition .register (Callable )
248- def _ (self , condition : ShouldStop , ** kwargs ):
249- return self .add_stop_condition (StopCondition (condition ), ** kwargs )
245+ def _ (self , condition : ShouldStop ):
246+ return self .add_stop_condition (StopCondition (condition ))
250247
251248 @add_stop_condition .register
252- def _ (self , condition : StopCondition , ** kwargs ):
249+ def _ (self , condition : StopCondition ):
253250
254251 if self ._debug_logger is not None :
255- self ._debug_logger .wrap (condition , kwargs .pop ('allow_re_wrapping' , False ))
256-
257- extra_kwargs_not_allowed (kwargs , 'add_stop_condition' )
252+ self ._debug_logger .wrap (condition )
258253
259254 self .stop_conditions .append (condition )
260255 if isinstance (condition , StopConditionWithContextValue ):
@@ -281,30 +276,27 @@ def matches_any_stop_condition(self, item: T, context: StepContext) -> bool:
281276
282277 @add_condition .register (QueueCondition )
283278 @singledispatchmethod
284- def add_queue_condition (self , condition : QueueConditionTypes , ** kwargs ) -> D :
279+ def add_queue_condition (self , condition : QueueConditionTypes ) -> D :
285280 """
286281 Adds a queue condition to the traversal.
287282 Queue conditions determine whether an item should be queued for traversal.
288283 All registered queue conditions must return true for an item to be queued.
289284
290285 :param condition: The queue condition to add.
291- :keyword allow_re_wrapping: Allow rewrapping of :class:`QueueCondition`s with debug logging
292286 :returns: The current traversal instance.
293287 """
294288
295289 raise RuntimeError (f'Condition [{ condition .__class__ .__name__ } ] does not match expected: [QueueCondition | QueueConditionWithContextValue | Callable]' )
296290
297291 @add_queue_condition .register (Callable )
298- def _ (self , condition : ShouldQueue , ** kwargs ):
299- return self .add_queue_condition (QueueCondition (condition ), ** kwargs )
292+ def _ (self , condition : ShouldQueue ):
293+ return self .add_queue_condition (QueueCondition (condition ))
300294
301295 @add_queue_condition .register
302- def _ (self , condition : QueueCondition , ** kwargs ):
296+ def _ (self , condition : QueueCondition ):
303297
304298 if self ._debug_logger is not None :
305- self ._debug_logger .wrap (condition , kwargs .pop ('allow_re_wrapping' , False ))
306-
307- extra_kwargs_not_allowed (kwargs , 'add_queue_condition' )
299+ self ._debug_logger .wrap (condition )
308300
309301 self .queue_conditions .append (condition )
310302 if isinstance (condition , QueueConditionWithContextValue ):
@@ -324,24 +316,21 @@ def copy_queue_conditions(self, other: Traversal[T, D]) -> D:
324316 return self
325317
326318 @singledispatchmethod
327- def add_step_action (self , action : StepActionTypes , ** kwargs ) -> D :
319+ def add_step_action (self , action : StepActionTypes ) -> D :
328320 """
329321 Adds an action to be performed on each item in the traversal, including the
330322 starting items.
331323
332324 :param action: The action to perform on each item.
333- :keyword allow_re_wrapping: Allow rewrapping of :class:`StepAction`s with debug logging
334325 :return: The current traversal instance.
335326 """
336327
337328 raise RuntimeError (f'StepAction [{ action .__class__ .__name__ } ] does not match expected: [StepAction | StepActionWithContextValue | Callable]' )
338329
339330 @add_step_action .register
340- def _ (self , action : StepAction , ** kwargs ):
331+ def _ (self , action : StepAction ):
341332 if self ._debug_logger is not None :
342- self ._debug_logger .wrap (action , kwargs .pop ('allow_re_wrapping' , False ))
343-
344- extra_kwargs_not_allowed (kwargs , 'add_step_action' )
333+ self ._debug_logger .wrap (action )
345334
346335 self .step_actions .append (action )
347336 if isinstance (action , StepActionWithContextValue ):
@@ -350,47 +339,45 @@ def _(self, action: StepAction, **kwargs):
350339
351340 @add_step_action .register (Callable )
352341 def _ (self , action : StepActionFunc , ** kwargs ):
353- return self .add_step_action (StepAction (action ), ** kwargs )
342+ return self .add_step_action (StepAction (action ))
354343
355344 @singledispatchmethod
356- def if_not_stopping (self , action : StepActionTypes , ** kwargs ) -> D :
345+ def if_not_stopping (self , action : StepActionTypes ) -> D :
357346 """
358347 Adds an action to be performed on each item that does not match any stop condition.
359348
360349 :param action: The action to perform on each non-stopping item.
361- :keyword allow_re_wrapping: Allow rewrapping of :class:`StepAction`s with debug logging
362350 :return: The current traversal instance.
363351 """
364352 raise RuntimeError (f'StepAction [{ action } ] does not match expected: [StepAction | StepActionWithContextValue | Callable]' )
365353
366354 @if_not_stopping .register (Callable )
367- def _ (self , action : StepActionFunc , ** kwargs ) -> D :
368- return self .add_step_action (lambda it , context : action (it , context ) if not context .is_stopping else None , ** kwargs )
355+ def _ (self , action : StepActionFunc ) -> D :
356+ return self .add_step_action (lambda it , context : action (it , context ) if not context .is_stopping else None )
369357
370358 @if_not_stopping .register
371- def _ (self , action : StepAction , ** kwargs ) -> D :
359+ def _ (self , action : StepAction ) -> D :
372360 action .apply = lambda it , context : action ._func (it , context ) if not context .is_stopping else None
373- return self .add_step_action (action , ** kwargs )
361+ return self .add_step_action (action )
374362
375363 @singledispatchmethod
376- def if_stopping (self , action : StepActionTypes , ** kwargs ) -> D :
364+ def if_stopping (self , action : StepActionTypes ) -> D :
377365 """
378366 Adds an action to be performed on each item that matches a stop condition.
379367
380368 :param action: The action to perform on each stopping item.
381- :keyword allow_re_wrapping: Allow rewrapping of :class:`StepActions`s with debug logging
382369 :return: The current traversal instance.
383370 """
384371 raise RuntimeError (f'StepAction [{ action } ] does not match expected: [StepAction | StepActionWithContextValue | Callable]' )
385372
386373 @if_stopping .register (Callable )
387- def _ (self , action : StepActionFunc , ** kwargs ) -> D :
388- return self .add_step_action (lambda it , context : action (it , context ) if context .is_stopping else None , ** kwargs )
374+ def _ (self , action : StepActionFunc ) -> D :
375+ return self .add_step_action (lambda it , context : action (it , context ) if context .is_stopping else None )
389376
390377 @if_stopping .register
391- def _ (self , action : StepAction , ** kwargs ) -> D :
378+ def _ (self , action : StepAction ) -> D :
392379 action .apply = lambda it , context : action ._func (it , context ) if context .is_stopping else None
393- return self .add_step_action (action , ** kwargs )
380+ return self .add_step_action (action )
394381
395382 def copy_step_actions (self , other : Traversal [T , D ]) -> D :
396383 """
0 commit comments