Skip to content

refactor(router): relocate Router module from tesla/vehicle to tesla/router.py#39

Merged
Bre77 merged 2 commits into
mainfrom
fm/router-relocate-m3
Jul 2, 2026
Merged

refactor(router): relocate Router module from tesla/vehicle to tesla/router.py#39
Bre77 merged 2 commits into
mainfrom
fm/router-relocate-m3

Conversation

@Bre77

@Bre77 Bre77 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Intent

Relocate the router module out of tesla/vehicle/ because it is not vehicle-specific: it exports the entity-agnostic Router base plus two peers, VehicleRouter and EnergySiteRouter. Move tesla/vehicle/router.py to tesla/router.py via git mv (logic unchanged; the module was already entity-agnostic with no vehicle-specific self-references). Fix every import site: tesla/init.py now imports the three names from tesla.router (its all still exports all three, preserving the top-level public API tesla_fleet_api.tesla.Router/VehicleRouter/EnergySiteRouter); tesla/vehicle/init.py drops the router re-exports. Also git mv tests/test_vehicle_router.py to tests/test_router.py since it now covers energy-site and N-way routing, update its import, and broaden its docstring. README.md and AGENTS.md docs are pointed at tesla.router. Deliberate decision: CLEAN BREAK, no backward-compat shim for the old tesla.vehicle.router path -- these classes are unreleased (they landed in PRs #37 and #38, after the last PyPI release v1.4.7), so no published artifact ever exposed the old submodule path; a shim would only preserve a path that never shipped. The committed tesla_fleet_api.egg-info/ build artifact still shows old paths but is intentionally left untouched because it regenerates on build. Validation already run locally: 36 tests pass, pyright strict 0 errors, ruff check clean, changed files ruff-format clean.

What Changed

  • Moved tesla/vehicle/router.py to tesla/router.py via git mv (logic unchanged — the module was already entity-agnostic, exporting the Router base plus VehicleRouter and EnergySiteRouter).
  • Rewired imports: tesla/__init__.py now pulls the three router names from tesla.router, and tesla/vehicle/__init__.py drops the router re-exports — the top-level public API (tesla_fleet_api.tesla.Router/VehicleRouter/EnergySiteRouter) is preserved. Clean break with no shim for the old tesla.vehicle.router path (unreleased, landed post-v1.4.7).
  • Renamed tests/test_vehicle_router.py to tests/test_router.py (updated import, broadened docstring to reflect energy-site and N-way routing coverage) and pointed README.md / AGENTS.md docs at tesla.router. Full suite passes (36 tests, 8 subtests).

Risk Assessment

✅ Low: Pure git-mv relocation of an already entity-agnostic module with all import sites and docs updated, no self-references or circular-import risk, and the public API preserved.

Testing

Beyond the baseline (36 tests pass, including the 25 relocated router tests), I demonstrated the actual end-user-facing intent — the public import surface — by running a Python script against the built package: it confirms the top-level tesla_fleet_api.tesla.Router/VehicleRouter/EnergySiteRouter API is preserved and identical to the new tesla.router module, the new canonical import path works, the old tesla.vehicle.router path is intentionally gone (raises ModuleNotFoundError — the clean break), and the vehicle package no longer re-exports the names. A grep confirms README/AGENTS docs were updated to the new path with no stale references. This is a pure Python import/packaging refactor with no UI surface, so the appropriate reviewer-visible evidence is the import-behavior transcript rather than a screenshot. Overall: intent satisfied.

Evidence: Public API import behavior transcript

== Top-level public API preserved (tesla_fleet_api.tesla.*) == Router -> tesla_fleet_api.tesla.router.Router VehicleRouter -> tesla_fleet_api.tesla.router.VehicleRouter EnergySiteRouter -> tesla_fleet_api.tesla.router.EnergySiteRouter all exports all three: True == New canonical module path works == from tesla_fleet_api.tesla.router import Router, VehicleRouter, EnergySiteRouter -> OK == Identity: top-level names ARE the tesla.router names == Router is router.Router: True VehicleRouter is router.VehicleRouter: True EnergySiteRouter is router.EnergySiteRouter: True == Clean break: old path tesla.vehicle.router is GONE == ModuleNotFoundError (expected): No module named 'tesla_fleet_api.tesla.vehicle.router' == vehicle package no longer re-exports router names == hasattr(tesla.vehicle, 'Router'): False hasattr(tesla.vehicle, 'VehicleRouter'): False hasattr(tesla.vehicle, 'EnergySiteRouter'): False

== Top-level public API preserved (tesla_fleet_api.tesla.*) ==
  Router             -> tesla_fleet_api.tesla.router.Router
  VehicleRouter      -> tesla_fleet_api.tesla.router.VehicleRouter
  EnergySiteRouter   -> tesla_fleet_api.tesla.router.EnergySiteRouter
  __all__ exports all three: True

== New canonical module path works ==
  from tesla_fleet_api.tesla.router import Router, VehicleRouter, EnergySiteRouter  -> OK

== Identity: top-level names ARE the tesla.router names ==
  Router is router.Router: True
  VehicleRouter is router.VehicleRouter: True
  EnergySiteRouter is router.EnergySiteRouter: True

== Clean break: old path tesla.vehicle.router is GONE ==
  ModuleNotFoundError (expected): No module named 'tesla_fleet_api.tesla.vehicle.router'

== vehicle package no longer re-exports router names ==
  hasattr(tesla.vehicle, 'Router'): False
  hasattr(tesla.vehicle, 'VehicleRouter'): False
  hasattr(tesla.vehicle, 'EnergySiteRouter'): False

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • uv run pytest tests/test_router.py -q — 25 relocated router tests pass (vehicle + energy-site + N-way routing)
  • uv run pytest tests -q — full suite: 36 passed, 8 subtests passed
  • Ran a Python script exercising every import surface: top-level tesla_fleet_api.tesla.{Router,VehicleRouter,EnergySiteRouter}, new tesla.router module path, identity checks (top-level names ARE the tesla.router names), old tesla.vehicle.router path raising ModuleNotFoundError, and vehicle package no longer exposing the names
  • grep scan of tesla_fleet_api/README.md/AGENTS.md — no stale vehicle.router references; docs point at tesla.router
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

firstmate crewmate and others added 2 commits July 2, 2026 20:36
The router module exports the entity-agnostic Router base plus the
VehicleRouter and EnergySiteRouter peers, so it is not vehicle-specific.
Relocate it next to energysite.py and fix every import site.

- git mv tesla/vehicle/router.py -> tesla/router.py (logic unchanged)
- git mv tests/test_vehicle_router.py -> tests/test_router.py (now also
  covers energy-site and N-way routing); broaden its module docstring
- tesla/__init__.py: import the three names from tesla.router; __all__
  still exports all three (top-level public API preserved)
- tesla/vehicle/__init__.py: drop the router re-exports
- README.md / AGENTS.md: point docs at tesla.router

Clean break, no back-compat shim: these classes are unreleased (landed in
#37/#38, after v1.4.7), so no published artifact exposed the old
tesla.vehicle.router path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Bre77 Bre77 merged commit 4cad84c into main Jul 2, 2026
3 checks passed
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