@@ -103,9 +103,7 @@ def __init__(
103103 container ,
104104 self ._state_manager ,
105105 )
106- self ._fallback_executor : FallbackStepExecutor [ContextT ] = FallbackStepExecutor [
107- ContextT
108- ](
106+ self ._fallback_executor : FallbackStepExecutor [ContextT ] = FallbackStepExecutor [ContextT ](
109107 context ,
110108 container ,
111109 self ._state_manager ,
@@ -146,11 +144,7 @@ async def __aexit__(
146144 # If an exception occurred, compensate all completed steps.
147145 # Do not compensate on GeneratorExit: consumer stopped iteration intentionally
148146 # (e.g. to resume later), which is not a failure.
149- if (
150- exc_val is not None
151- and exc_type is not GeneratorExit
152- and not self ._compensated
153- ):
147+ if exc_val is not None and exc_type is not GeneratorExit and not self ._compensated :
154148 self ._error = exc_val
155149 await self ._compensate ()
156150 return False # Don't suppress the exception
@@ -214,25 +208,19 @@ async def __aiter__(
214208 # POINT OF NO RETURN: Strict Backward Recovery Strategy
215209 if status in (SagaStatus .COMPENSATING , SagaStatus .FAILED ):
216210 logger .warning (
217- f"Saga { self ._saga_id } is in { status } state. "
218- "Resuming compensation immediately." ,
211+ f"Saga { self ._saga_id } is in { status } state. " "Resuming compensation immediately." ,
219212 )
220213
221214 # Restore completed steps from history for compensation
222- completed_act_steps = (
223- await self ._recovery_manager .load_completed_step_names ()
224- )
225- reconstructed_steps = (
226- await self ._recovery_manager .reconstruct_completed_steps (
227- completed_act_steps ,
228- )
215+ completed_act_steps = await self ._recovery_manager .load_completed_step_names ()
216+ reconstructed_steps = await self ._recovery_manager .reconstruct_completed_steps (
217+ completed_act_steps ,
229218 )
230219 # Type cast is safe here because steps are reconstructed from the same saga
231220 # that uses ContextT, so they have the correct context type
232221 # We need to rebuild the list to satisfy type checker's invariance requirements
233222 self ._completed_steps = [
234- typing .cast (SagaStepHandler [ContextT , typing .Any ], step )
235- for step in reconstructed_steps
223+ typing .cast (SagaStepHandler [ContextT , typing .Any ], step ) for step in reconstructed_steps
236224 ]
237225
238226 if not self ._completed_steps :
@@ -253,9 +241,7 @@ async def __aiter__(
253241 )
254242
255243 # For RUNNING/PENDING status, load history to skip completed steps
256- completed_step_names = (
257- await self ._recovery_manager .load_completed_step_names ()
258- )
244+ completed_step_names = await self ._recovery_manager .load_completed_step_names ()
259245 except ValueError :
260246 # If loading fails but ID was provided, create it
261247 await self ._state_manager .create_saga (
0 commit comments