Skip to content

Commit

Permalink
cleanup of repository root, adding ruff as linter and formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
fredriklj committed Dec 18, 2024
1 parent f22112b commit 5e54f2d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 35 deletions.
28 changes: 4 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions custom_components/porscheconnect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")
Expand Down Expand Up @@ -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)
Expand All @@ -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(),
),
),
)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions custom_components/porscheconnect/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for the Porsche Connect binary sensors."""

from __future__ import annotations

import logging
Expand Down
11 changes: 8 additions & 3 deletions custom_components/porscheconnect/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config flow for Porsche Connect integration."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -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 = {}
Expand All @@ -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(
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions custom_components/porscheconnect/number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for the Porsche Connect number entities."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions custom_components/porscheconnect/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for the Porsche Connect sensors."""

from __future__ import annotations

import logging
Expand Down
Binary file removed example.png
Binary file not shown.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" ]
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pre-commit==4.0.1
black==24.10.0
flake8==7.1.1
ruff>=0.8
homeassistant
pyporscheconnectapi
pytest

0 comments on commit 5e54f2d

Please sign in to comment.