From 257b67d8fd0239d9865fc575b7227d025f19027f Mon Sep 17 00:00:00 2001 From: "GitHub Action action@github.com" Date: Mon, 5 Feb 2024 19:28:08 +0000 Subject: [PATCH] :file_folder: ruff > Made via .github/workflows/a_pre_commit.yml --- custom_components/xplora_watch/__init__.py | 4 +--- .../xplora_watch/binary_sensor.py | 6 +---- custom_components/xplora_watch/config_flow.py | 19 ++++++--------- .../xplora_watch/const_schema.py | 12 ++-------- custom_components/xplora_watch/coordinator.py | 24 ++++++------------- .../xplora_watch/device_tracker.py | 5 +--- custom_components/xplora_watch/entity.py | 2 +- custom_components/xplora_watch/geocoder.py | 4 ++-- custom_components/xplora_watch/helper.py | 3 +-- custom_components/xplora_watch/sensor.py | 14 ++--------- custom_components/xplora_watch/services.py | 7 +++--- custom_components/xplora_watch/switch.py | 9 ++----- scripts/update/hacs.py | 2 +- 13 files changed, 31 insertions(+), 80 deletions(-) diff --git a/custom_components/xplora_watch/__init__.py b/custom_components/xplora_watch/__init__.py index a201ed19..7ba83f98 100644 --- a/custom_components/xplora_watch/__init__.py +++ b/custom_components/xplora_watch/__init__.py @@ -7,9 +7,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_ENTITY_ID, CONF_NAME, Platform from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import aiohttp_client, discovery -from homeassistant.helpers import config_validation as cv -from homeassistant.helpers import entity_registry as er +from homeassistant.helpers import aiohttp_client, config_validation as cv, discovery, entity_registry as er from homeassistant.helpers.typing import ConfigType from .const import DATA_HASS_CONFIG, DOMAIN diff --git a/custom_components/xplora_watch/binary_sensor.py b/custom_components/xplora_watch/binary_sensor.py index 3d1647dc..c057276a 100644 --- a/custom_components/xplora_watch/binary_sensor.py +++ b/custom_components/xplora_watch/binary_sensor.py @@ -5,11 +5,7 @@ import logging from typing import Any -from homeassistant.components.binary_sensor import ( - BinarySensorDeviceClass, - BinarySensorEntity, - BinarySensorEntityDescription, -) +from homeassistant.components.binary_sensor import BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_ID, diff --git a/custom_components/xplora_watch/config_flow.py b/custom_components/xplora_watch/config_flow.py index 414a2ac5..766f6a45 100644 --- a/custom_components/xplora_watch/config_flow.py +++ b/custom_components/xplora_watch/config_flow.py @@ -2,23 +2,13 @@ from __future__ import annotations -import logging from collections import OrderedDict +import logging from types import MappingProxyType from typing import Any -import voluptuous as vol -from pyxplora_api.exception_classes import Error, LoginError, PhoneOrEmailFail -from pyxplora_api.pyxplora_api_async import PyXploraApi -from pyxplora_api.status import UserContactType - -import homeassistant.helpers.config_validation as cv from homeassistant import config_entries, core -from homeassistant.config_entries import ( - ConfigEntry, - OptionsFlow, - OptionsFlowWithConfigEntry, -) +from homeassistant.config_entries import ConfigEntry, OptionsFlow, OptionsFlowWithConfigEntry from homeassistant.const import ( ATTR_LATITUDE, ATTR_LONGITUDE, @@ -33,6 +23,7 @@ from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.selector import ( BooleanSelector, NumberSelector, @@ -46,6 +37,10 @@ TextSelectorConfig, TextSelectorType, ) +from pyxplora_api.exception_classes import Error, LoginError, PhoneOrEmailFail +from pyxplora_api.pyxplora_api_async import PyXploraApi +from pyxplora_api.status import UserContactType +import voluptuous as vol from .const import ( CONF_HOME_LATITUDE, diff --git a/custom_components/xplora_watch/const_schema.py b/custom_components/xplora_watch/const_schema.py index dffeea8b..730e99bf 100644 --- a/custom_components/xplora_watch/const_schema.py +++ b/custom_components/xplora_watch/const_schema.py @@ -2,8 +2,6 @@ from __future__ import annotations -import voluptuous as vol - from homeassistant.const import CONF_COUNTRY_CODE, CONF_EMAIL, CONF_LANGUAGE, CONF_PASSWORD from homeassistant.helpers.selector import ( SelectOptionDict, @@ -14,15 +12,9 @@ TextSelectorConfig, TextSelectorType, ) +import voluptuous as vol -from .const import ( - CONF_PHONENUMBER, - CONF_TIMEZONE, - CONF_USERLANG, - DEFAULT_LANGUAGE, - SUPPORTED_LANGUAGES, - XPLORA_USER_LANGS, -) +from .const import CONF_PHONENUMBER, CONF_TIMEZONE, CONF_USERLANG, DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, XPLORA_USER_LANGS DEFAULT_DATA_SCHEMA = { vol.Required(CONF_PASSWORD): TextSelector(TextSelectorConfig(type=TextSelectorType.PASSWORD)), diff --git a/custom_components/xplora_watch/coordinator.py b/custom_components/xplora_watch/coordinator.py index b53f7c65..c9e5cbd3 100644 --- a/custom_components/xplora_watch/coordinator.py +++ b/custom_components/xplora_watch/coordinator.py @@ -2,31 +2,21 @@ from __future__ import annotations -import logging from datetime import datetime, timedelta +import logging from typing import Any import aiohttp -from pyxplora_api.const import DEFAULT_TIMEOUT -from pyxplora_api.model import ChatsNew -from pyxplora_api.pyxplora_api_async import PyXploraApi -from pyxplora_api.status import LocationType, WatchOnlineStatus - -from homeassistant.components.device_tracker.const import ( - ATTR_BATTERY, - ATTR_LOCATION_NAME, -) +from homeassistant.components.device_tracker.const import ATTR_BATTERY, ATTR_LOCATION_NAME from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - CONF_COUNTRY_CODE, - CONF_EMAIL, - CONF_LANGUAGE, - CONF_PASSWORD, - CONF_SCAN_INTERVAL, -) +from homeassistant.const import CONF_COUNTRY_CODE, CONF_EMAIL, CONF_LANGUAGE, CONF_PASSWORD, CONF_SCAN_INTERVAL from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client from homeassistant.helpers.update_coordinator import DataUpdateCoordinator +from pyxplora_api.const import DEFAULT_TIMEOUT +from pyxplora_api.model import ChatsNew +from pyxplora_api.pyxplora_api_async import PyXploraApi +from pyxplora_api.status import LocationType, WatchOnlineStatus from .const import ( API_KEY_MAPBOX, diff --git a/custom_components/xplora_watch/device_tracker.py b/custom_components/xplora_watch/device_tracker.py index a7648f2a..9140d5ae 100644 --- a/custom_components/xplora_watch/device_tracker.py +++ b/custom_components/xplora_watch/device_tracker.py @@ -7,10 +7,7 @@ from homeassistant.components.device_tracker import SourceType from homeassistant.components.device_tracker.config_entry import TrackerEntity -from homeassistant.components.device_tracker.const import ( - ATTR_BATTERY, - ATTR_LOCATION_NAME, -) +from homeassistant.components.device_tracker.const import ATTR_BATTERY, ATTR_LOCATION_NAME from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ID, CONF_NAME from homeassistant.core import HomeAssistant diff --git a/custom_components/xplora_watch/entity.py b/custom_components/xplora_watch/entity.py index 65558f0f..28ef2aee 100644 --- a/custom_components/xplora_watch/entity.py +++ b/custom_components/xplora_watch/entity.py @@ -2,8 +2,8 @@ from __future__ import annotations -import logging from collections.abc import Callable +import logging from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback diff --git a/custom_components/xplora_watch/geocoder.py b/custom_components/xplora_watch/geocoder.py index 3cffc02b..ce029d17 100644 --- a/custom_components/xplora_watch/geocoder.py +++ b/custom_components/xplora_watch/geocoder.py @@ -12,10 +12,10 @@ from __future__ import annotations import collections -import os -import sys from datetime import datetime from decimal import Decimal +import os +import sys import backoff import requests diff --git a/custom_components/xplora_watch/helper.py b/custom_components/xplora_watch/helper.py index b12b3134..c5f5193f 100644 --- a/custom_components/xplora_watch/helper.py +++ b/custom_components/xplora_watch/helper.py @@ -10,14 +10,13 @@ from typing import Any from geopy import distance -from pydub import AudioSegment - from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, CONF_LANGUAGE from homeassistant.core import HomeAssistant from homeassistant.loader import DATA_CUSTOM_COMPONENTS from homeassistant.util.yaml import save_yaml from homeassistant.util.yaml.loader import load_yaml +from pydub import AudioSegment from .const import ( ATTR_SERVICE_DELETE_MSG, diff --git a/custom_components/xplora_watch/sensor.py b/custom_components/xplora_watch/sensor.py index 655b7ae0..3eea517d 100644 --- a/custom_components/xplora_watch/sensor.py +++ b/custom_components/xplora_watch/sensor.py @@ -5,19 +5,9 @@ import logging from typing import Any -from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorEntity, - SensorEntityDescription, -) +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_ID, - CONF_NAME, - PERCENTAGE, - EntityCategory, - UnitOfLength, -) +from homeassistant.const import ATTR_ID, CONF_NAME, PERCENTAGE, EntityCategory, UnitOfLength from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType diff --git a/custom_components/xplora_watch/services.py b/custom_components/xplora_watch/services.py index dfb3835e..500cf948 100644 --- a/custom_components/xplora_watch/services.py +++ b/custom_components/xplora_watch/services.py @@ -5,11 +5,10 @@ import logging from typing import Any -import voluptuous as vol -from pyxplora_api.exception_classes import NoAdminError - -import homeassistant.helpers.config_validation as cv from homeassistant.core import HomeAssistant, ServiceCall, callback +import homeassistant.helpers.config_validation as cv +from pyxplora_api.exception_classes import NoAdminError +import voluptuous as vol from .const import ( ATTR_SERVICE_DELETE_MSG, diff --git a/custom_components/xplora_watch/switch.py b/custom_components/xplora_watch/switch.py index 63f7e2c4..da0adda2 100644 --- a/custom_components/xplora_watch/switch.py +++ b/custom_components/xplora_watch/switch.py @@ -5,17 +5,12 @@ import logging from typing import Any -from pyxplora_api.pyxplora_api_async import PyXploraApi - -from homeassistant.components.switch import ( - SwitchDeviceClass, - SwitchEntity, - SwitchEntityDescription, -) +from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity, SwitchEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ID, CONF_LANGUAGE, CONF_NAME from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback +from pyxplora_api.pyxplora_api_async import PyXploraApi from .const import ( ATTR_SERVICE_USER, diff --git a/scripts/update/hacs.py b/scripts/update/hacs.py index 6deff421..3b21123c 100644 --- a/scripts/update/hacs.py +++ b/scripts/update/hacs.py @@ -3,8 +3,8 @@ import json import os -import sys from pathlib import Path +import sys HACS_FILE = Path(f"{os.getcwd()}/hacs.json")