diff --git a/custom_components/gasbuddy/__init__.py b/custom_components/gasbuddy/__init__.py index 8f87a01..316f1c9 100644 --- a/custom_components/gasbuddy/__init__.py +++ b/custom_components/gasbuddy/__init__.py @@ -2,22 +2,17 @@ from __future__ import annotations import asyncio -from datetime import timedelta import logging +from datetime import timedelta +from gasbuddy import GasBuddy # pylint: disable=import-self +# pylint: disable-next=import-error,no-name-in-module +from gasbuddy.exceptions import APIError, LibraryError from homeassistant.config_entries import ConfigEntry from homeassistant.core import Config, HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed -from gasbuddy import GasBuddy # pylint: disable=import-self - -# pylint: disable-next=import-error,no-name-in-module -from gasbuddy.exceptions import ( - APIError, - LibraryError, -) - from .const import ( CONF_INTERVAL, CONF_STATION_ID, diff --git a/custom_components/gasbuddy/config_flow.py b/custom_components/gasbuddy/config_flow.py index 8d31b87..3202e80 100644 --- a/custom_components/gasbuddy/config_flow.py +++ b/custom_components/gasbuddy/config_flow.py @@ -4,17 +4,16 @@ import logging from typing import Any +import gasbuddy import voluptuous as vol from homeassistant import config_entries from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult from homeassistant.util import slugify -import gasbuddy - from .const import ( - CONF_NAME, CONF_INTERVAL, + CONF_NAME, CONF_POSTAL, CONF_STATION_ID, DEFAULT_NAME, diff --git a/custom_components/gasbuddy/const.py b/custom_components/gasbuddy/const.py index 797eced..9a08eb9 100644 --- a/custom_components/gasbuddy/const.py +++ b/custom_components/gasbuddy/const.py @@ -3,9 +3,7 @@ from typing import Final -from homeassistant.components.sensor import ( - SensorEntityDescription, -) +from homeassistant.components.sensor import SensorEntityDescription # config flow CONF_STATION_ID = "station_id" diff --git a/custom_components/gasbuddy/sensor.py b/custom_components/gasbuddy/sensor.py index 9452f63..a104ad2 100644 --- a/custom_components/gasbuddy/sensor.py +++ b/custom_components/gasbuddy/sensor.py @@ -5,8 +5,8 @@ from typing import Any, Optional from homeassistant.components.sensor import SensorEntity, SensorEntityDescription -from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.config_entries import ConfigEntry +from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ( diff --git a/setup.cfg b/setup.cfg index 63e6e6b..c5f69b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,13 @@ +[mypy] +python_version = 3.11 +show_error_codes = true +ignore_errors = true +follow_imports = silent +ignore_missing_imports = true +warn_incomplete_stub = true +warn_redundant_casts = true +warn_unused_configs = true + [flake8] exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build doctests = True @@ -16,20 +26,8 @@ ignore = W504 [isort] -# https://github.com/timothycrosley/isort -# https://github.com/timothycrosley/isort/wiki/isort-Settings -# splits long import on multiple lines indented by 4 spaces multi_line_output = 3 include_trailing_comma=True force_grid_wrap=0 use_parentheses=True line_length=88 -indent = " " -# by default isort don't check module indexes -not_skip = __init__.py -# will group `import x` and `from x import` of the same module. -force_sort_within_sections = true -sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -default_section = THIRDPARTY -known_first_party = custom_components.gasbuddy -combine_as_imports = true diff --git a/tests/conftest.py b/tests/conftest.py index 62e15b3..59a1d73 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,9 @@ """Global fixtures for gasbuddy integration.""" -import pytest from unittest.mock import patch +import pytest + from tests.const import COORDINATOR_DATA diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 2f5dedc..1bcd887 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,8 +1,12 @@ """Test config flow.""" -from tests.const import CONFIG_DATA from unittest.mock import patch + +from homeassistant import config_entries, data_entry_flow, setup +from homeassistant.const import CONF_NAME +from homeassistant.data_entry_flow import FlowResult, FlowResultType import pytest +from pytest_homeassistant_custom_component.common import MockConfigEntry from custom_components.gasbuddy.const import ( CONF_INTERVAL, @@ -12,12 +16,7 @@ DEFAULT_NAME, DOMAIN, ) -from tests.const import STATION_LIST - -from homeassistant import config_entries, data_entry_flow, setup -from homeassistant.const import CONF_NAME -from pytest_homeassistant_custom_component.common import MockConfigEntry -from homeassistant.data_entry_flow import FlowResult, FlowResultType +from tests.const import CONFIG_DATA, STATION_LIST pytestmark = pytest.mark.asyncio diff --git a/tests/test_init.py b/tests/test_init.py index 572861e..cbcc3f4 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -1,12 +1,10 @@ """Test gasbuddy setup process.""" -import pytest - -from custom_components.gasbuddy.const import DOMAIN - from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +import pytest from pytest_homeassistant_custom_component.common import MockConfigEntry +from custom_components.gasbuddy.const import DOMAIN from tests.const import CONFIG_DATA pytestmark = pytest.mark.asyncio diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 41bf82f..6428c93 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,13 +1,12 @@ """Test gasbuddy sensors.""" +from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN import pytest +from pytest_homeassistant_custom_component.common import MockConfigEntry from custom_components.gasbuddy.const import DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN -from pytest_homeassistant_custom_component.common import MockConfigEntry - from .const import CONFIG_DATA pytestmark = pytest.mark.asyncio