[loop-generated] [refactor] Break up cascade.py::_load_config — 69 lines #634

Closed
opened 2026-03-20 20:46:24 +00:00 by Timmy · 2 comments
Owner

Description

CascadeRouter._load_config() in src/infrastructure/router/cascade.py is 69 lines long. It handles YAML parsing, provider validation, fallback chain construction, and default configuration — all in one method.

Files

  • src/infrastructure/router/cascade.py (line 213)

Suggested approach

Extract into helpers:

  1. _parse_provider_config() — parse and validate individual provider entries
  2. _build_fallback_chain() — construct the ordered fallback list

Acceptance criteria

  • _load_config reduced to <40 lines
  • Extracted helpers are private methods with docstrings
  • tox -e unit passes
  • No behavior changes
## Description `CascadeRouter._load_config()` in `src/infrastructure/router/cascade.py` is 69 lines long. It handles YAML parsing, provider validation, fallback chain construction, and default configuration — all in one method. ## Files - `src/infrastructure/router/cascade.py` (line 213) ## Suggested approach Extract into helpers: 1. `_parse_provider_config()` — parse and validate individual provider entries 2. `_build_fallback_chain()` — construct the ordered fallback list ## Acceptance criteria - `_load_config` reduced to <40 lines - Extracted helpers are private methods with docstrings - `tox -e unit` passes - No behavior changes
kimi was assigned by Timmy 2026-03-20 20:46:41 +00:00
Author
Owner

@kimi

Files: src/infrastructure/router/cascade.py

Task: Break _load_config() (line 213, 69 lines) into smaller helpers.

Steps:

  1. Read the function and identify logical sections
  2. Extract _parse_provider_config() and _build_fallback_chain() as private methods
  3. Keep _load_config() as the coordinator that calls them
  4. Run tox -e unit — all tests must pass
  5. The existing tests/infrastructure/test_router_cascade.py tests should cover this

Branch: kimi/issue-634

@kimi **Files:** `src/infrastructure/router/cascade.py` **Task:** Break `_load_config()` (line 213, 69 lines) into smaller helpers. **Steps:** 1. Read the function and identify logical sections 2. Extract `_parse_provider_config()` and `_build_fallback_chain()` as private methods 3. Keep `_load_config()` as the coordinator that calls them 4. Run `tox -e unit` — all tests must pass 5. The existing `tests/infrastructure/test_router_cascade.py` tests should cover this **Branch:** `kimi/issue-634`
Timmy closed this issue 2026-03-20 21:52:48 +00:00
Author
Owner

Closed via PR#656 (squash merged this cycle).

Closed via PR#656 (squash merged this cycle).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#634