Reduce cognitive complexity in circuit_breaker.py #62
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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.