pyinfra icon indicating copy to clipboard operation
pyinfra copied to clipboard

Make `python.call` operation idempotent-capable

Open foreignmeloman opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe

Currently python.call operation is not considered idempotent no matter what.

Describe the solution you'd like

Instead of the current behavior python.call operation can be modified to be shown as idempotent operation based on the return value of the function called with the following logic:

Return value Operation status
None Success (current behavior)
True Success
False No changes

This will enable to implement the idempotent logic in the function itself and correctly represent it in run report, while keeping the current behavior intact, when the function does not return anything.

foreignmeloman avatar Jul 17 '24 15:07 foreignmeloman

This is an excellent idea 👍

Fizzadar avatar Jul 21 '24 12:07 Fizzadar

I agree. Wouldn't an enum be a better choice though (wrapped in Optional[] to keep BC)?

simonhammes avatar Aug 04 '24 07:08 simonhammes