Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Add support for diagnostics (#37)
Browse files Browse the repository at this point in the history
* Bump library version

* Add diagnostics

* Update requirements

* pre-commit autoupdate

* Remove Python 3.8 from CI, add 3.9

* Black

* Decrease min test coverage
  • Loading branch information
bieniu authored Feb 26, 2022
1 parent b947111 commit 24bdc85
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 38 deletions.
57 changes: 29 additions & 28 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Push

on: [push, pull_request]
"on": [push, pull_request]

jobs:
check:
Expand All @@ -9,32 +10,32 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
pip install -r requirements-test.txt
- name: Check with isort
run: |
isort custom_components/zadnego_ale tests --check-only
- name: Check with Black Code Formatter
run: |
black custom_components/zadnego_ale tests --check
- name: Lint with flake8
run: |
flake8 custom_components/zadnego_ale tests
- name: Lint with pylint
run: |
pylint custom_components/zadnego_ale
- name: Test with mypy
run: |
mypy custom_components/zadnego_ale
- name: Test with pytest
run: |
pytest tests
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
pip install -r requirements-test.txt
- name: Check with isort
run: |
isort custom_components/zadnego_ale tests --check-only
- name: Check with Black Code Formatter
run: |
black custom_components/zadnego_ale tests --check
- name: Lint with flake8
run: |
flake8 custom_components/zadnego_ale tests
- name: Lint with pylint
run: |
pylint custom_components/zadnego_ale
- name: Test with mypy
run: |
mypy custom_components/zadnego_ale
- name: Test with pytest
run: |
pytest tests
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.1
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
args:
Expand Down Expand Up @@ -36,7 +36,7 @@ repos:
- mccabe==0.6.1
files: ^(custom_components/zadnego_ale|tests)/.+\.py$
- repo: https://github.com/PyCQA/bandit
rev: 1.7.1
rev: 1.7.2
hooks:
- id: bandit
args:
Expand All @@ -47,7 +47,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: no-commit-to-branch
args:
Expand Down
24 changes: 24 additions & 0 deletions custom_components/zadnego_ale/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Diagnostics support for Zadnego Ale."""
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from . import ZadnegoAleDataUpdateCoordinator
from .const import DOMAIN


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
) -> dict:
"""Return diagnostics for a config entry."""
coordinator: ZadnegoAleDataUpdateCoordinator = hass.data[DOMAIN][
config_entry.entry_id
]

diagnostics_data = {
"config_entry_data": dict(config_entry.data),
"coordinator_data": coordinator.data,
}

return diagnostics_data
4 changes: 2 additions & 2 deletions custom_components/zadnego_ale/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"documentation": "https://github.com/bieniu/ha-zadnego-ale",
"issue_tracker": "https://github.com/bieniu/ha-zadnego-ale/issues",
"codeowners": ["@bieniu"],
"requirements": ["zadnegoale==0.6.0"],
"requirements": ["zadnegoale==0.6.2"],
"config_flow": true,
"version": "0.6.0",
"version": "0.6.4",
"iot_class": "cloud_polling"
}
6 changes: 3 additions & 3 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ aiohttp_cors==0.7.0
black==22.1.0
coverage>=6.0.2
flake8==4.0.1
homeassistant>=2021.11.0b0
homeassistant
isort==5.10.1
mypy==0.931
pre-commit==2.17.0
pylint==2.12.2
pytest-cov>=2.12.1
pytest-homeassistant-custom-component
pytest-homeassistant-custom-component==0.6.18
pytest
zadnegoale==0.6.1
zadnegoale==0.6.2
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ exclude_lines =
raise NotImplemented()
if __name__ == '__main__':
main()
fail_under = 93
fail_under = 90
show_missing = true

0 comments on commit 24bdc85

Please sign in to comment.