Skip to content

refactor: Phase 1 — slim weather_client_base.py (remove stubs, extract merge helper)#454

Merged
Orinks merged 6 commits intodevfrom
refactor/monolith-phase1
Mar 14, 2026
Merged

refactor: Phase 1 — slim weather_client_base.py (remove stubs, extract merge helper)#454
Orinks merged 6 commits intodevfrom
refactor/monolith-phase1

Conversation

@Orinks
Copy link
Owner

@Orinks Orinks commented Mar 14, 2026

Summary

Executes Phase 1 of the monolith refactor per .planning/phases/phase-1/PLAN.md.

  • Task 1 — Deleted 13 one-line delegation stub methods from WeatherClient (_convert_*, _normalize_*, _degrees_to_cardinal, _weather_code_to_description, _format_date_name, _normalize_datetime). These were pure pass-throughs to parsers.* with no logic of their own. Updated 3 test files that were testing the stubs via client._* to call parsers.* directly.
  • Task 2 — Removed private _convert_f_to_c and _degrees_to_cardinal methods from VisualCrossingClient (lines 848–876) that duplicated identical implementations in weather_client_parsers.py. Extended the existing parsers import and replaced all 10 call sites.
  • Task 3 — Extracted _merge_current_conditions from WeatherClient to a module-level merge_current_conditions function in weather_client_parsers.py. The method was purely functional (no self state). Added TYPE_CHECKING guard for CurrentConditions annotation. Re-added weather_client_parsers as parsers import to weather_client_base.py (had been auto-removed by ruff after Task 1 dropped the stubs that used it).
  • Task 4 — Added tests/test_parsers_merge.py with 8 test cases for merge_current_conditions.

Line count changes

File Before After Delta
weather_client_base.py 1,399 1,303 −96
visual_crossing_client.py 876 846 −30
weather_client_parsers.py 245 303 +58

Test plan

  • python3 -m pytest --tb=short -q — 2649 passed, 7 pre-existing integration failures (API-key dependent), no regressions
  • grep -rn "self\._convert_\|self\._merge_current_conditions" src/accessiweather/ — 0 results
  • python3 -m ruff check on touched files — no errors
  • No circular imports introduced (all three modules import cleanly)
  • 4 separate commits as specified in the plan

Scope note

Per the plan's honest scope note: after Phase 1, weather_client_base.py is ~1,303 lines — not the original <900 target. The unit conversion methods were already stubs (partial extraction had occurred previously). A follow-up phase targeting parse delegation stubs (~250 more lines) is needed to reach <900.

🤖 Generated with Claude Code

Orinks and others added 6 commits March 14, 2026 22:14
Deleted 13 one-line _convert_* / _normalize_* / _degrees_to_cardinal /
_weather_code_to_description / _format_date_name / _normalize_datetime stubs
(lines 1351-1399) that were pure delegation stubs to parsers.* functions.
Updated TestWeatherClientHelpers tests to call parsers.* directly instead of
going through now-removed WeatherClient stubs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…with parsers imports

Removed _convert_f_to_c and _degrees_to_cardinal private methods from
VisualCrossingClient (lines 848-876) which duplicated implementations already
in weather_client_parsers.py. Extended the parsers import at line 25 and
replaced all self._ call sites with direct function calls. Updated helper
tests in test_visual_crossing_client.py and test_weather_client_integration.py
to call parsers functions directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…in parsers

Moved _merge_current_conditions from WeatherClient class body to a standalone
merge_current_conditions function in weather_client_parsers.py. The method
accessed no instance state — pure function taking two CurrentConditions attrs
instances. Added to __all__ and TYPE_CHECKING guard for CurrentConditions.
Updated the single call site in _augment_current_with_openmeteo to use
parsers.merge_current_conditions(). Re-added weather_client_parsers import
alias (had been auto-removed as unused after Task 1 deleted the stubs).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8 test cases covering: primary=None returns fallback, primary wins when
populated, fallback fills None fields, fallback fills empty-string fields,
both-None stays None, valid object after merge, fallback not mutated,
multiple fields merged at once.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Orinks Orinks merged commit ffb4f0c into dev Mar 14, 2026
6 checks passed
@Orinks Orinks deleted the refactor/monolith-phase1 branch March 14, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant