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

Add pre-commit check #6

Merged
merged 4 commits into from
Jan 2, 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
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on:
push:
branches: [master]
pull_request: ~

env:
FORCE_COLOR: 1

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ repos:
- id: check-toml
- id: check-added-large-files
- id: check-json
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
- id: mypy
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.8.3
rev: 'v0.8.5'
hooks:
- id: ruff
args: [ --fix ]
- id: ruff
args:
- '--fix'
- id: ruff-format
2 changes: 1 addition & 1 deletion custom_components/premium_bond_checker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Premium Bond Checker integration."""
"""Premium Bond Checker integration."""

import logging

Expand Down
2 changes: 1 addition & 1 deletion custom_components/premium_bond_checker/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Coordinator for Premium Bond Checker integration. """
"""Coordinator for Premium Bond Checker integration."""

import logging
from datetime import timedelta
Expand Down
11 changes: 7 additions & 4 deletions custom_components/premium_bond_checker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import logging

from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from premium_bond_checker.client import Result

Expand Down Expand Up @@ -74,16 +76,17 @@ def name(self) -> str:
def unique_id(self) -> str:
return self._id


class PremiumBondCheckerDetailSensor(CoordinatorEntity, SensorEntity):
def __init__(self, coordinator, holder_number: str, bond_period: str, detail_type: str):
def __init__(
self, coordinator, holder_number: str, bond_period: str, detail_type: str
):
"""Initialize the sensor."""
super().__init__(coordinator)
self._data = coordinator
self._bond_period = bond_period
self._detail_type = detail_type
self._name = (
f"Premium Bond Checker {holder_number} {BOND_PERIODS_TO_NAME[bond_period]} {detail_type}"
)
self._name = f"Premium Bond Checker {holder_number} {BOND_PERIODS_TO_NAME[bond_period]} {detail_type}"
self._id = f"premium_bond_checker-{holder_number}-{bond_period}-{detail_type}"

@property
Expand Down
Loading