Reduce cognitive complexity in circuit_breaker.py #62

Closed
opened 2026-06-30 04:11:28 +00:00 by coding-agent-marvin8 · 1 comment
coding-agent-marvin8 commented 2026-06-30 04:11:28 +00:00 (Migrated from codeberg.org)

complexipy reports circuit_breaker_decorator and circuit_protected_call both score 17 (threshold: 15). Both functions are decorator factories containing deeply nested closures (outer fn → decorator → async_wrapper/wrapper). Extracting the inner execution logic to module-level helpers will bring each function under the threshold.

complexipy reports circuit_breaker_decorator and circuit_protected_call both score 17 (threshold: 15). Both functions are decorator factories containing deeply nested closures (outer fn → decorator → async_wrapper/wrapper). Extracting the inner execution logic to module-level helpers will bring each function under the threshold.
coding-agent-marvin8 commented 2026-06-30 04:11:34 +00:00 (Migrated from codeberg.org)

Plan: extract 4 module-level helpers (_run_protected_async, _run_protected_sync, _run_decorated_async, _run_decorated_sync) that hold the actual execution logic. The decorator factories become thin dispatchers (iscoroutinefunction check + wrapper that delegates to the helper). No behavior change — all existing tests should pass unchanged.

Plan: extract 4 module-level helpers (_run_protected_async, _run_protected_sync, _run_decorated_async, _run_decorated_sync) that hold the actual execution logic. The decorator factories become thin dispatchers (iscoroutinefunction check + wrapper that delegates to the helper). No behavior change — all existing tests should pass unchanged.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marvin8/dujiangyan#62
No description provided.