diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1bda09c..398e4bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,6 @@ repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.3 hooks: - - id: check-added-large-files - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - - repo: local - hooks: - - id: black - name: black - entry: black - language: system - types: [python] - require_serial: true - - id: flake8 - name: flake8 - entry: flake8 - language: system - types: [python] - require_serial: true - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 - hooks: - - id: prettier + - id: ruff + - id: ruff-format diff --git a/custom_components/porscheconnect/__init__.py b/custom_components/porscheconnect/__init__.py index cb434b3..87be3ed 100644 --- a/custom_components/porscheconnect/__init__.py +++ b/custom_components/porscheconnect/__init__.py @@ -28,6 +28,7 @@ _LOGGER = logging.getLogger(__name__) SCAN_INTERVAL = timedelta(seconds=DEFAULT_SCAN_INTERVAL) + def get_from_dict(datadict, keystring): """Safely get value from dict.""" maplist = keystring.split(".") @@ -74,13 +75,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): ) coordinator = PorscheConnectDataUpdateCoordinator( - hass, config_entry=entry, controller=controller, + hass, + config_entry=entry, + controller=controller, ) await coordinator.async_config_entry_first_refresh() hass.data[DOMAIN][entry.entry_id] = coordinator await hass.config_entries.async_forward_entry_setups( - entry, list(PLATFORMS), + entry, + list(PLATFORMS), ) _async_save_token(hass, entry, controller.token) @@ -102,7 +106,8 @@ def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, controller): seconds=config_entry.options.get( CONF_SCAN_INTERVAL, config_entry.data.get( - CONF_SCAN_INTERVAL, SCAN_INTERVAL.total_seconds(), + CONF_SCAN_INTERVAL, + SCAN_INTERVAL.total_seconds(), ), ), ) @@ -145,7 +150,8 @@ async def _async_update_data(self): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms( - entry, list(PLATFORMS), + entry, + list(PLATFORMS), ) if unload_ok: diff --git a/custom_components/porscheconnect/binary_sensor.py b/custom_components/porscheconnect/binary_sensor.py index d24031b..f0b7f0a 100644 --- a/custom_components/porscheconnect/binary_sensor.py +++ b/custom_components/porscheconnect/binary_sensor.py @@ -1,4 +1,5 @@ """Support for the Porsche Connect binary sensors.""" + from __future__ import annotations import logging diff --git a/custom_components/porscheconnect/config_flow.py b/custom_components/porscheconnect/config_flow.py index 8c85def..eb4fbb6 100644 --- a/custom_components/porscheconnect/config_flow.py +++ b/custom_components/porscheconnect/config_flow.py @@ -1,4 +1,5 @@ """Config flow for Porsche Connect integration.""" + from __future__ import annotations import logging @@ -77,7 +78,8 @@ async def async_step_user(self, user_input=None): """Handle the initial step.""" if user_input is None: return self.async_show_form( - step_id="user", data_schema=STEP_USER_DATA_SCHEMA, + step_id="user", + data_schema=STEP_USER_DATA_SCHEMA, ) errors = {} @@ -104,7 +106,9 @@ async def async_step_user(self, user_input=None): errors["base"] = "invalid_auth" return self.async_show_form( - step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors, + step_id="user", + data_schema=STEP_USER_DATA_SCHEMA, + errors=errors, ) async def async_step_reauth( @@ -117,7 +121,8 @@ async def async_step_reauth( return await self.async_step_user() async def async_step_captcha( - self, user_input: dict[str, str] | None = None, + self, + user_input: dict[str, str] | None = None, ) -> config_entries.ConfigFlowResult: """Captcha verification step.""" if user_input is not None: diff --git a/custom_components/porscheconnect/number.py b/custom_components/porscheconnect/number.py index 32d37aa..87cb25e 100644 --- a/custom_components/porscheconnect/number.py +++ b/custom_components/porscheconnect/number.py @@ -1,4 +1,5 @@ """Support for the Porsche Connect number entities.""" + from __future__ import annotations import logging diff --git a/custom_components/porscheconnect/sensor.py b/custom_components/porscheconnect/sensor.py index 12b37f3..fc3f638 100644 --- a/custom_components/porscheconnect/sensor.py +++ b/custom_components/porscheconnect/sensor.py @@ -1,4 +1,5 @@ """Support for the Porsche Connect sensors.""" + from __future__ import annotations import logging diff --git a/example.png b/example.png deleted file mode 100644 index c2d4244..0000000 Binary files a/example.png and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml index 8d7fdff..714ae1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,6 @@ +[tool.ruff] +exclude = [ "tests/*.py" ] + [tool.ruff.lint] select = [ "ALL" ] -ignore = [ "ANN001", "ANN201", "ANN202", "ANN204", "ARG001", "TC002", "TC003" ] - +ignore = [ "ANN001", "ANN201", "ANN202", "ANN204", "ARG001", "TC002", "TC003", "COM812", "ISC001" ] diff --git a/requirements_dev.txt b/requirements_dev.txt index 8c6c50d..c012ccc 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,6 +1,5 @@ pre-commit==4.0.1 -black==24.10.0 -flake8==7.1.1 +ruff>=0.8 homeassistant pyporscheconnectapi pytest