Skip to content

Commit

Permalink
Add pre-commit setup, SVG icon, HACS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Jan 4, 2024
1 parent 06dc3bc commit 5d0977b
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/validate-hacs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Validate with hassfest

on:
push:
pull_request:
schedule:
- cron: 0 0 * * *

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: home-assistant/actions/hassfest@master
hacs:
name: HACS Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: HACS Action
uses: hacs/action@main
with:
category: integration
109 changes: 109 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
---
files: ^(.*\.(py|json|md|sh|yaml|cfg|txt))$
exclude: ^(\.[^/]*cache/.*|.*/_user.py)$
repos:
- repo: https://github.com/verhovsky/pyupgrade-docs
rev: v0.3.0
hooks:
- id: pyupgrade-docs

- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.16
hooks:
- id: mdformat
name: Format Markdown
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
args: [--wrap, '75', --number]
additional_dependencies:
- mdformat-toc
- mdformat-beautysh
# -mdformat-shfmt
# -mdformat-tables
- mdformat-config
- mdformat-black
- mdformat-web
- mdformat-gfm
- setuptools

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
Expand All @@ -12,6 +41,9 @@ repos:
- id: check-toml
# - id: check-yaml
- id: debug-statements
- id: check-shebang-scripts-are-executable
- id: fix-byte-order-marker
- id: check-case-conflict

- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
Expand All @@ -29,3 +61,80 @@ repos:
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
hooks:
- id: yamllint
args:
- --no-warnings
- -d
- '{extends: relaxed, rules: {line-length: {max: 90}}}'

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py310-plus

- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
rev: v1.0.6
hooks:
- id: python-bandit-vulnerability-check

- repo: https://github.com/fsouza/autoflake8
rev: v0.4.0
hooks:
- id: autoflake8
args:
- -i
- -r
- --expand-star-imports
- custom_components

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
# - pyproject-flake8>=0.0.1a5
- flake8-bugbear>=22.7.1
- flake8-comprehensions>=3.10.1
- flake8-2020>=1.7.0
- mccabe>=0.7.0
- pycodestyle>=2.9.1
- pyflakes>=2.5.0

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
args:
# - --builtin=clear,rare,informal,usage,code,names,en-GB_to_en-US
- --builtin=clear,rare,informal,usage,code,names
- --ignore-words-list=hass,master
- --skip="./.*"
- --quiet-level=2
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.3
hooks:
- id: pylint
additional_dependencies:
- homeassistant-stubs>=2023.2.0
- sqlalchemy
- pyyaml

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
additional_dependencies:
- homeassistant-stubs>=2023.2.0
- sqlalchemy
- pyyaml
4 changes: 1 addition & 3 deletions custom_components/delorian/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"domain": "delorian",
"name": "Delorian - Testing integration for historical sensors",
"after_dependencies": ["recorder"],
"codeowners": [
"@ldotlopez"
],
"dependencies": [
"recorder"
],
"config_flow": true,
"documentation": "https://github.com/ldotlopez/ha-historical-sensor",
"iot_class": "cloud_polling",
Expand Down
8 changes: 8 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Delorian - Testing integration for historical sensors",
"content_in_root": false,
"zip_release": false,
"render_readme": true,
"persistent_directory": "local",
"homeassistant": "2023.1"
}
2 changes: 1 addition & 1 deletion homeassistant_historical_sensor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def should_poll(self):
def state(self):
# Better report unavailable than anything
#
# Another aproach is to return data from historical entity, but causes
# Another approach is to return data from historical entity, but causes
# wrong results. Keep here for reference.
#
# HistoricalSensors doesn't use poll but state is accessed only once when
Expand Down
Binary file modified icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,44 @@ target-version = ['py311']
[tool.isort]
profile = "black"

known_first_party = [
"homeassistant",
"tests",
]
forced_separate = [
"tests",
]

[tool.mypy]
files = ['homeassistant_historical_sensor']

[tool.setuptools]
packages = ["homeassistant_historical_sensor"]

[tool.pylint.MAIN]
py-version = "3.11"
ignore = [
"tests",
]
persistent = false

[tool.pylint.BASIC]
class-const-naming-style = "any"
good-names = [
"r",
"g",
"v",
]

[tool.pylint."MESSAGES CONTROL"]
disable = [
"line-too-long",
"too-few-public-methods",
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"too-many-locals",
]

[tool.pylint.FORMAT]
expected-line-ending-format = "LF"

0 comments on commit 5d0977b

Please sign in to comment.