Skip to content

Commit

Permalink
Merge pull request #41 from hudsonbrendon/fix/type-hints
Browse files Browse the repository at this point in the history
fix: add type hints in methods
  • Loading branch information
hudsonbrendon authored Jan 7, 2025
2 parents 3e34012 + 50b4be7 commit 338ffdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions custom_components/drivvo/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Mapping
import logging
from typing import Any
from typing import Any, Dict

import voluptuous as vol

Expand Down Expand Up @@ -152,7 +152,7 @@ def __init__(self) -> None:
self.user: str
self.password: str

async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
async def async_step_import(self, import_config: Dict[str, Any]) -> FlowResult:
"""Import existing configuration."""

if (f"{DOMAIN}_{import_config.get(CONF_EMAIL)}").lower() in [
Expand Down Expand Up @@ -183,7 +183,7 @@ async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
},
)

async def async_step_user(self, user_input=None):
async def async_step_user(self, user_input=None) -> FlowResult:
errors = {}

if user_input is not None:
Expand Down Expand Up @@ -218,7 +218,7 @@ async def async_step_user(self, user_input=None):
async def async_step_vehicle(
self,
user_input=None,
):
) -> FlowResult:
errors = {}

if user_input is not None:
Expand Down
12 changes: 6 additions & 6 deletions custom_components/drivvo/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any
from typing import Any, Dict

import voluptuous as vol

Expand Down Expand Up @@ -111,7 +111,7 @@ async def async_setup_platform(


class DrivvoSensor(Entity):
def __init__(self, hass, email, password, data, interval):
def __init__(self, hass, email, password, data, interval) -> None:
"""Inizialize sensor."""
self._attr_unique_id = f"{data.id}_refuellings"
self._attr_has_entity_name = True
Expand All @@ -134,17 +134,17 @@ def __init__(self, hass, email, password, data, interval):
self.data = data

@property
def icon(self):
def icon(self) -> str:
"""Return the default icon."""
return ICON

@property
def state(self):
def state(self) -> int:
"""Returns the number of supplies so far."""
return self.data.refuelling_total

@property
def extra_state_attributes(self):
def extra_state_attributes(self) -> Dict[str, Any]:
"""Attributes."""

return {
Expand All @@ -168,7 +168,7 @@ def extra_state_attributes(self):
"refuelling_volume_total": self.data.refuelling_volume_total,
}

async def async_update(self):
async def async_update(self) -> None:
"""Updates the data by making a request to the API."""
self.data = await get_data_vehicle(
hass=self.hass,
Expand Down

0 comments on commit 338ffdb

Please sign in to comment.