mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
Refactored config_flow.py (995 lines) into focused modules within config_flow/ package to improve maintainability and code organization. Changes: - Created config_flow/ package with 6 specialized modules (1,260 lines total) - Extracted validators to validators.py (95 lines) - pure, testable functions - Extracted schemas to schemas.py (577 lines) - centralized vol.Schema definitions - Split flow handlers into separate files: * user_flow.py (274 lines) - Main config flow (setup + reauth) * subentry_flow.py (124 lines) - Subentry flow (add homes) * options_flow.py (160 lines) - Options flow (6-step configuration wizard) - Package exports via __init__.py (50 lines) for backward compatibility - Deleted config_flow_legacy.py (no longer needed) Technical improvements: - Used Mapping[str, Any] for config_entry.options compatibility - Proper TYPE_CHECKING imports for circular dependency management - All 10 inline vol.Schema definitions replaced with reusable functions - Validators are pure functions (no side effects, easily testable) - Clear separation of concerns (validation, schemas, flows) Documentation: - Updated AGENTS.md with new package structure - Updated config flow patterns and examples - Added "Add a new config flow step" guide to Common Tasks - Marked refactoring plan as COMPLETED with lessons learned Verification: - All linting checks pass (./scripts/lint-check) - All flow handlers import successfully - Home Assistant loads integration without errors - All flow types functional (user, subentry, options, reauth) - No user-facing changes (backward compatible) Impact: Improves code maintainability by organizing 995 lines into 6 focused modules (avg 210 lines/module). Enables easier testing, future modifications, and onboarding of new contributors. |
||
|---|---|---|
| .. | ||
| binary_sensor | ||
| config_flow | ||
| custom_translations | ||
| entity_utils | ||
| period_utils | ||
| sensor | ||
| translations | ||
| __init__.py | ||
| api.py | ||
| average_utils.py | ||
| const.py | ||
| coordinator.py | ||
| data.py | ||
| diagnostics.py | ||
| entity.py | ||
| manifest.json | ||
| price_utils.py | ||
| services.py | ||
| services.yaml | ||