Skip to content
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

fix: add type hints in methods #41

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading