From 55db3f25ef1169933b38217afcecaf800f899091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B6rrle?= Date: Tue, 13 Feb 2024 10:04:14 +0100 Subject: [PATCH] fix liniting errors --- mytoyota/api.py | 8 ++++++++ mytoyota/controller.py | 1 + mytoyota/models/dashboard.py | 11 +++++++++++ mytoyota/models/endpoints/electric.py | 1 + mytoyota/models/endpoints/trips.py | 2 ++ mytoyota/models/endpoints/vehicle_guid.py | 1 + mytoyota/models/location.py | 4 ++++ mytoyota/models/nofication.py | 3 +++ mytoyota/models/service_history.py | 8 ++++++++ mytoyota/models/summary.py | 10 ++++++++++ mytoyota/models/trips.py | 11 +++++++++++ mytoyota/models/vehicle.py | 11 +++++++++++ 12 files changed, 71 insertions(+) diff --git a/mytoyota/api.py b/mytoyota/api.py index a9dc0ce4..f29eda4d 100644 --- a/mytoyota/api.py +++ b/mytoyota/api.py @@ -46,6 +46,7 @@ def __init__(self, controller: Controller) -> None: Returns: ------- None + """ self.controller = controller @@ -96,6 +97,7 @@ async def get_location_endpoint(self, vin: str) -> LocationResponseModel: Returns: ------- LocationResponseModel: A pydantic model for the location response + """ parsed_response = await self._request_and_parse( LocationResponseModel, "GET", VEHICLE_LOCATION_ENDPOINT, vin=vin @@ -116,6 +118,7 @@ async def get_vehicle_health_status_endpoint(self, vin: str) -> VehicleHealthRes Returns: ------- VehicleHealthResponseModel: A pydantic model for the vehicle health response + """ parsed_response = await self._request_and_parse( VehicleHealthResponseModel, "GET", VEHICLE_HEALTH_STATUS_ENDPOINT, vin=vin @@ -147,6 +150,7 @@ async def get_vehicle_electric_status_endpoint(self, vin: str) -> ElectricRespon Returns: ------- ElectricResponseModel: A pydantic model for the electric response + """ parsed_response = await self._request_and_parse( ElectricResponseModel, @@ -169,6 +173,7 @@ async def get_telemetry_endpoint(self, vin: str) -> TelemetryResponseModel: Returns: ------- TelemetryResponseModel: A pydantic model for the telemetry response + """ parsed_response = await self._request_and_parse( TelemetryResponseModel, "GET", VEHICLE_TELEMETRY_ENDPOINT, vin=vin @@ -190,6 +195,7 @@ async def get_notification_endpoint(self, vin: str) -> NotificationResponseModel Returns: ------- NotificationResponseModel: A pydantic model for the notification response + """ parsed_response = await self._request_and_parse( NotificationResponseModel, @@ -230,6 +236,7 @@ async def get_trips_endpoint( # noqa: PLR0913 Returns: ------- TripsResponseModel: A pydantic model for the trips response + """ endpoint = VEHICLE_TRIPS_ENDPOINT.format( from_date=from_date, @@ -257,6 +264,7 @@ async def get_service_history_endpoint(self, vin: str) -> ServiceHistoryResponse Returns: ------- ServicHistoryResponseModel: A pydantic model for the service history response + """ parsed_response = await self._request_and_parse( ServiceHistoryResponseModel, "GET", VEHICLE_SERVICE_HISTORY_ENDPONT, vin=vin diff --git a/mytoyota/controller.py b/mytoyota/controller.py index 5c15b2ab..6178fe48 100644 --- a/mytoyota/controller.py +++ b/mytoyota/controller.py @@ -298,6 +298,7 @@ async def request_json( # noqa: PLR0913 Examples: -------- response = await request_json("GET", "/cars", vin="1234567890") + """ response = await self.request_raw(method, endpoint, vin, body, params, headers) diff --git a/mytoyota/models/dashboard.py b/mytoyota/models/dashboard.py index ed121056..402fac4c 100644 --- a/mytoyota/models/dashboard.py +++ b/mytoyota/models/dashboard.py @@ -31,6 +31,7 @@ def __init__( # noqa: D417 Parameters ---------- metric: bool: Report distances in metric(or imperial) + """ self._electric: Optional[ElectricStatusModel] = electric.payload if electric else None self._telemetry: Optional[TelemetryModel] = telemetry.payload if telemetry else None @@ -54,6 +55,7 @@ def odometer(self) -> Optional[float]: Returns ------- The latest odometer reading in the current selected units + """ if self._telemetry: return convert_distance( @@ -70,6 +72,7 @@ def fuel_level(self) -> Optional[int]: Returns ------- A value as percentage + """ return self._telemetry.fuel_level if self._telemetry else None @@ -80,6 +83,7 @@ def battery_level(self) -> Optional[float]: Returns ------- A value as percentage + """ return self._electric.battery_level if self._electric else None @@ -93,6 +97,7 @@ def fuel_range(self) -> Optional[float]: If vehicle is electric returns 0 If vehicle doesn't support fuel range returns None + """ if self._electric and self._electric.fuel_range: return convert_distance( @@ -119,6 +124,7 @@ def battery_range(self) -> Optional[float]: If vehicle is fuel only returns None If vehicle doesn't support battery range returns None + """ if self._electric: return convert_distance( @@ -139,6 +145,7 @@ def battery_range_with_ac(self) -> Optional[float]: If vehicle is fuel only returns 0 If vehicle doesn't support battery range returns 0 + """ if self._electric: return convert_distance( @@ -161,6 +168,7 @@ def range(self) -> Optional[float]: ev only == battery_range_with_ac hybrid == fuel_range + battery_range_with_ac None if not supported + """ if self._telemetry and self._telemetry.distance_to_empty: return convert_distance( @@ -179,6 +187,7 @@ def charging_status(self) -> Optional[str]: ------- A string containing the charging status as reported by the vehicle None if vehicle doesn't support charging + """ return self._electric.charging_status if self._electric else None @@ -191,6 +200,7 @@ def remaining_charge_time(self) -> Optional[timedelta]: The amount of time left None if vehicle is not currently charging. None if vehicle doesn't support charging + """ return ( timedelta(minutes=self._electric.remaining_charge_time) @@ -206,5 +216,6 @@ def warning_lights(self) -> Optional[List[Any]]: ------- List of latest dashboard warning lights _Note_ Not fully understood + """ return self._health.warning if self._health else None diff --git a/mytoyota/models/endpoints/electric.py b/mytoyota/models/endpoints/electric.py index f5655b52..83c5d72b 100644 --- a/mytoyota/models/endpoints/electric.py +++ b/mytoyota/models/endpoints/electric.py @@ -22,6 +22,7 @@ class ElectricStatusModel(BaseModel): fuel_range (UnitValueModel): The fuel range of the electric vehicle. last_update_timestamp (datetime): The timestamp of the last update. remaining_charge_time Optional[int]: The time till full in minutes. + """ battery_level: int = Field(alias="batteryLevel") diff --git a/mytoyota/models/endpoints/trips.py b/mytoyota/models/endpoints/trips.py index 044261f6..ad758575 100644 --- a/mytoyota/models/endpoints/trips.py +++ b/mytoyota/models/endpoints/trips.py @@ -34,6 +34,7 @@ def __add__(self, other: _SummaryBaseModel): Args: ---- other: _SummaryBaseModel: to be added + """ if other is not None: self.length += other.length @@ -101,6 +102,7 @@ def __add__(self, other: _HDCModel): Args: ---- other: _SummaryBaseModel: to be added + """ if other is not None: self.ev_time = add_with_none(self.ev_time, other.ev_time) diff --git a/mytoyota/models/endpoints/vehicle_guid.py b/mytoyota/models/endpoints/vehicle_guid.py index 2072fd87..c8391a84 100644 --- a/mytoyota/models/endpoints/vehicle_guid.py +++ b/mytoyota/models/endpoints/vehicle_guid.py @@ -356,6 +356,7 @@ class VehicleGuidModel(BaseModel): vehicle_capabilities (List[Any]): The capabilities of the vehicle. vehicle_data_consents (Optional[Any]): The vehicle data consents of the vehicle. vin (str): The VIN (Vehicle Identification Number) of the vehicle. + """ alerts: List[Any] # TODO unsure what this returns diff --git a/mytoyota/models/location.py b/mytoyota/models/location.py index 15277ea6..5fa86102 100644 --- a/mytoyota/models/location.py +++ b/mytoyota/models/location.py @@ -31,6 +31,7 @@ def latitude(self) -> Optional[float]: Returns ------- Latest latitude or None. _Not always available_. + """ return self._location.latitude if self._location else None @@ -41,6 +42,7 @@ def longitude(self) -> Optional[float]: Returns ------- Latest longitude or None. _Not always available_. + """ return self._location.longitude if self._location else None @@ -51,6 +53,7 @@ def timestamp(self) -> Optional[datetime]: Returns ------- Position aquired timestamp or None. _Not always available_. + """ return self._location.location_acquisition_datetime if self._location else None @@ -61,5 +64,6 @@ def state(self) -> str: Returns ------- The state of the position or None. _Not always available_. + """ return self._location.display_name if self._location else None diff --git a/mytoyota/models/nofication.py b/mytoyota/models/nofication.py index 1f36b4ba..48cc2b92 100644 --- a/mytoyota/models/nofication.py +++ b/mytoyota/models/nofication.py @@ -31,6 +31,7 @@ def category(self) -> str: Returns ------- str: Category of notification + """ return self._notification.category @@ -65,6 +66,7 @@ def type(self) -> str: Returns ------- str: Notification type + """ return self._notification.type @@ -75,5 +77,6 @@ def date(self) -> datetime: Returns ------- datime: Time of notification + """ return self._notification.notification_date diff --git a/mytoyota/models/service_history.py b/mytoyota/models/service_history.py index 8479bb49..3c90de7d 100644 --- a/mytoyota/models/service_history.py +++ b/mytoyota/models/service_history.py @@ -35,6 +35,7 @@ def service_date(self) -> date: Returns ------- date: The date of the service. + """ return self._service_history.service_date @@ -45,6 +46,7 @@ def customer_created_record(self) -> bool: Returns ------- str: Category of notification + """ return self._service_history.customer_created_record @@ -78,6 +80,7 @@ def notes(self) -> Any: Returns ------- Any: Additional notes about the service + """ return self._service_history.notes @@ -88,6 +91,7 @@ def operations_performed(self) -> Any: Returns ------- Any: The operations performed during the service + """ return self._service_history.operations_performed @@ -98,6 +102,7 @@ def ro_number(self) -> Any: Returns ------- Any: The RO (Repair Order) number associated with the service + """ return self._service_history.ro_number @@ -108,6 +113,7 @@ def service_category(self) -> str: Returns ------- str: The category of the service. + """ return self._service_history.service_category @@ -118,6 +124,7 @@ def service_provider(self) -> str: Returns ------- str: The service provider + """ return self._service_history.service_provider @@ -128,5 +135,6 @@ def servicing_dealer(self) -> Any: Returns ------- Any: The dealer that performed the service + """ return self._service_history.servicing_dealer diff --git a/mytoyota/models/summary.py b/mytoyota/models/summary.py index d0735d13..adb65ec8 100644 --- a/mytoyota/models/summary.py +++ b/mytoyota/models/summary.py @@ -36,6 +36,7 @@ def __init__( # noqa: PLR0913 from_date (date, required): Start date for this summary to_date (date, required): End date for this summary hdc: (_HDCModel, optional): Hybrid data if available + """ self._summary: _SummaryBaseModel = summary self._hdc: Optional[_HDCModel] = hdc @@ -80,6 +81,7 @@ def countries(self) -> List[str]: ------- List[str]: List of countries visited in 'ISO 3166-1 alpha-2' or two-letter country codes format. + """ return self._summary.countries @@ -90,6 +92,7 @@ def duration(self) -> timedelta: Returns ------- timedelta: The amount of time driving + """ return timedelta(seconds=self._summary.duration) @@ -100,6 +103,7 @@ def distance(self) -> float: Returns ------- float: Distance covered in the selected metric + """ return convert_distance(self._distance_unit, "km", self._summary.length / 1000.0) @@ -110,6 +114,7 @@ def ev_duration(self) -> Optional[timedelta]: Returns ------- timedelta: The amount of time driving using EV or None if not supported + """ if self._hdc and self._hdc.ev_time: return timedelta(seconds=self._hdc.ev_time) @@ -122,6 +127,7 @@ def ev_distance(self) -> Optional[float]: Returns ------- timedelta: The distance driven using EV in selected metric or None if not supported + """ if self._hdc and self._hdc.ev_distance: return convert_distance(self._distance_unit, "km", self._hdc.ev_distance / 1000.0) @@ -134,6 +140,7 @@ def from_date(self) -> date: Returns ------- date: The date the summary started + """ return self._from_date @@ -144,6 +151,7 @@ def to_date(self) -> date: Returns ------- date: The date the summary ended + """ return self._to_date @@ -154,6 +162,7 @@ def fuel_consumed(self) -> float: Returns ------- float: The total amount of fuel consumed in liters if metric or gallons + """ if self._summary.fuel_consumption: return ( @@ -171,6 +180,7 @@ def average_fuel_consumed(self) -> float: Returns ------- float: The average amount of fuel consumed in l/100km if metric or mpg + """ if self._summary.fuel_consumption: avg_fuel_consumed = (self._summary.fuel_consumption / self._summary.length) * 100 diff --git a/mytoyota/models/trips.py b/mytoyota/models/trips.py index b34358dc..ad5b71e7 100644 --- a/mytoyota/models/trips.py +++ b/mytoyota/models/trips.py @@ -20,6 +20,7 @@ def __init__( ---- trip (_TripModel, required): Contains all information regarding the trip metric (bool, required): Report in Metric or Imperial + """ self._trip = trip self._metric = "km" if metric else "mi" @@ -41,6 +42,7 @@ def start_location(self) -> Tuple[float, float]: Returns ------- Tuple[float, float]: Start location (Lat, Lon) + """ return self._trip.summary.start_lat, self._trip.summary.start_lon @@ -51,6 +53,7 @@ def end_location(self) -> Tuple[float, float]: Returns ------- Tuple[float, float]: End location (Lat, Lon) + """ return self._trip.summary.end_lat, self._trip.summary.end_lon @@ -61,6 +64,7 @@ def start_time(self) -> datetime: Returns ------- datetime: Start time of trip + """ return self._trip.summary.start_ts @@ -71,6 +75,7 @@ def end_time(self) -> datetime: Returns ------- datetime: End time of trip + """ return self._trip.summary.end_ts @@ -81,6 +86,7 @@ def duration(self) -> timedelta: Returns ------- timedelta: The amount of time driving + """ return timedelta(seconds=self._trip.summary.duration) @@ -91,6 +97,7 @@ def distance(self) -> float: Returns ------- float: Distance covered in the selected metric + """ return convert_distance(self._metric, "km", self._trip.summary.length / 1000.0) @@ -101,6 +108,7 @@ def ev_duration(self) -> Optional[timedelta]: Returns ------- timedelta: The amount of time driving using EV or None if not supported + """ return timedelta(seconds=self._trip.hdc.ev_time) if self._trip.hdc else None @@ -111,6 +119,7 @@ def ev_distance(self) -> Optional[float]: Returns ------- timedelta: The distance driven using EV in selected metric or None if not supported + """ return ( convert_distance(self._metric, "km", self._trip.hdc.ev_distance / 1000.0) @@ -125,6 +134,7 @@ def fuel_consumed(self) -> float: Returns ------- float: The fuel consumed in liters if metric or gallons + """ if self._trip.summary.fuel_consumption: return ( @@ -143,6 +153,7 @@ def route(self) -> Optional[List[Tuple[float, float]]]: ------- Optional[List[Tuple[float, float]]]: List of Lat, Lon of the route taken. None if no route provided. + """ if self._trip.route: return [(rm.lat, rm.lon) for rm in self._trip.route] diff --git a/mytoyota/models/vehicle.py b/mytoyota/models/vehicle.py index e016dd9b..610ead48 100644 --- a/mytoyota/models/vehicle.py +++ b/mytoyota/models/vehicle.py @@ -142,6 +142,7 @@ def type(self) -> Optional[str]: "mildhybrid" if hybrid "phev" if plugin hybrid "ev" if full electric vehicle + """ # TODO enum # TODO currently guessing until we see a mild hybrid and full EV @@ -159,6 +160,7 @@ def dashboard(self) -> Optional[Dashboard]: Returns ------- A dashboard + """ # Always returns a Dashboard object as we can always get the odometer value return Dashboard( @@ -182,6 +184,7 @@ def location(self) -> Optional[Location]: providing location information. _Note_ an empty location object can be returned when the Vehicle supports location but none is currently available. + """ return ( Location(self._endpoint_data["location"]) @@ -253,6 +256,7 @@ def lock_status(self) -> Optional[LockStatus]: ------- Optional[LockStatus]: The latest lock status of Doors & Windows, or None if not supported. + """ return LockStatus( self._endpoint_data["status"] if "status" in self._endpoint_data else None @@ -283,6 +287,7 @@ async def get_summary( Returns: ------- List[Summary]: A list of summaries or empty list if not supported. + """ if to_date > date.today(): # Future dates not allowed to_date = date.today() @@ -313,6 +318,7 @@ async def get_current_day_summary(self) -> Optional[Summary]: Returns ------- Optional[Summary]: A summary or None if not supported. + """ summary = await self.get_summary( from_date=Arrow.now().date(), @@ -328,6 +334,7 @@ async def get_current_week_summary(self) -> Optional[Summary]: Returns ------- Optional[Summary]: A summary or None if not supported. + """ summary = await self.get_summary( from_date=Arrow.now().floor("week").date(), @@ -343,6 +350,7 @@ async def get_current_month_summary(self) -> Optional[Summary]: Returns ------- Optional[Summary]: A summary or None if not supported. + """ summary = await self.get_summary( from_date=Arrow.now().floor("month").date(), @@ -358,6 +366,7 @@ async def get_current_year_summary(self) -> Optional[Summary]: Returns ------- Optional[Summary]: A summary or None if not supported. + """ summary = await self.get_summary( from_date=Arrow.now().floor("year").date(), @@ -381,6 +390,7 @@ async def get_trips( Returns: ------- Optional[List[Something]]: A list of all trips or None if not supported. + """ ret: List[Trip] = [] offset = 0 @@ -421,6 +431,7 @@ async def set_alias(self, value) -> bool: Returns: ------- bool + """ return value