refactor(router): relocate Router module from tesla/vehicle to tesla/router.py#39
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
tesla/vehicle/router.pytotesla/router.pyviagit mv(logic unchanged — the module was already entity-agnostic, exporting theRouterbase plusVehicleRouterandEnergySiteRouter).tesla/__init__.pynow pulls the three router names fromtesla.router, andtesla/vehicle/__init__.pydrops 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 oldtesla.vehicle.routerpath (unreleased, landed post-v1.4.7).tests/test_vehicle_router.pytotests/test_router.py(updated import, broadened docstring to reflect energy-site and N-way routing coverage) and pointed README.md / AGENTS.md docs attesla.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/EnergySiteRouterAPI is preserved and identical to the newtesla.routermodule, the new canonical import path works, the oldtesla.vehicle.routerpath 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'): FalsePipeline
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 passedRan a Python script exercising every import surface: top-leveltesla_fleet_api.tesla.{Router,VehicleRouter,EnergySiteRouter}, newtesla.routermodule path, identity checks (top-level names ARE the tesla.router names), oldtesla.vehicle.routerpath raising ModuleNotFoundError, and vehicle package no longer exposing the namesgrepscan of tesla_fleet_api/README.md/AGENTS.md — no stalevehicle.routerreferences; docs point attesla.router✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.