Repository navigation
feat(ble-extra): make Bluetooth support an optional extra (tesla-fleet-api[ble]) #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4fedf69
334c41d
44b9c54
857ba6e
43fbf8c
6ba2bfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,19 @@ You can install the library using pip: | |
| pip install tesla-fleet-api | ||
| ``` | ||
|
|
||
| Bluetooth support (`TeslaBluetooth`, `VehicleBluetooth`, `createBluetooth()`) pulls in | ||
| `bleak` and `bleak-retry-connector`, so it ships as the optional `ble` extra rather than | ||
| a base dependency — cloud-only consumers (Fleet API, Teslemetry, Tessie) don't need to | ||
| carry it. If you use Bluetooth, install with: | ||
|
|
||
| ```bash | ||
| pip install tesla-fleet-api[ble] | ||
| ``` | ||
|
|
||
| Existing installs that already depend on `bleak`/`bleak-retry-connector` directly, or | ||
| that pin `tesla-fleet-api` without extras, keep working: add the `[ble]` extra (or keep | ||
| your own `bleak` pin) to continue resolving those packages going forward. | ||
|
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Require both Bluetooth dependencies when retaining direct pins. A direct 🤖 Prompt for AI Agents |
||
|
|
||
| ## Usage | ||
|
|
||
| ### Authentication | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,32 @@ | ||
| """Tesla Fleet API classes.""" | ||
|
|
||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from tesla_fleet_api.tesla.vehicle.vehicles import Vehicles, VehiclesBluetooth | ||
| from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet | ||
| from tesla_fleet_api.tesla.vehicle.bluetooth import VehicleBluetooth | ||
| from tesla_fleet_api.tesla.vehicle.signed import VehicleSigned | ||
| from tesla_fleet_api.tesla.vehicle.vehicle import Vehicle | ||
| from tesla_fleet_api.util import import_ble_class | ||
|
|
||
| if TYPE_CHECKING: | ||
| from tesla_fleet_api.tesla.vehicle.bluetooth import ( | ||
| VehicleBluetooth as VehicleBluetooth, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "Vehicles", | ||
| "VehiclesBluetooth", | ||
| "Vehicle", | ||
| "VehicleFleet", | ||
| "VehicleBluetooth", | ||
| "VehicleSigned", | ||
| ] | ||
|
|
||
|
|
||
| def __getattr__(name: str) -> Any: | ||
| # VehicleBluetooth requires bleak (the "ble" extra); import it lazily so | ||
| # importing this package doesn't require bleak to be installed. | ||
| if name == "VehicleBluetooth": | ||
| return import_ble_class( | ||
| "tesla_fleet_api.tesla.vehicle.bluetooth", "VehicleBluetooth" | ||
| ) | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Quote the
bleextra in every pip command. An unquoted[ble]is a filename pattern. With zsh’sNOMATCHbehavior, the command can fail before pip runs. Usepip install 'tesla-fleet-api[ble]'. (zsh.sourceforge.io)README.md#L29-L29: quote the extra in the installation example.docs/bluetooth_vehicles.md#L5-L5: quote the extra in the prerequisite command.tesla_fleet_api/util.py#L20-L20: quote the extra in the error message users copy.Based on learnings, quote pip install arguments that contain extras syntax.
📍 Affects 3 files
README.md#L29-L29(this comment)docs/bluetooth_vehicles.md#L5-L5tesla_fleet_api/util.py#L20-L20🤖 Prompt for AI Agents
Source: Learnings