Skip to content

Commit

Permalink
Update pre-commit hoooks and related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Sep 17, 2023
1 parent e1f9600 commit 3a76f59
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/gen_stats.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DEST=$(dirname $0)/../../STATS.md
DEST=$(dirname "$0")/../../STATS.md

TEMPLATE='- ![badge VERSION](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/VERSION/total.svg)'

Expand All @@ -12,7 +12,7 @@ EXCLUDES="v0.7.9 v0.7.7 v0.7.6 v0.7.5 v0.7.3 v0.7.2 v0.7.1 v0.7.23 v0.7.24 v0.8.
echo
for tag in latest $(git tag -l --sort=-creatordate v*[0-9]) ; do
if [[ "$EXCLUDES" != *"$tag"* ]] ; then
echo ${TEMPLATE//VERSION/$tag}
echo "${TEMPLATE//VERSION/$tag}"
fi
done
) > "${DEST}"
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: pyupgrade-docs
- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
name: Format Markdown
Expand All @@ -26,34 +26,34 @@ repos:
- mdformat-web
- mdformat-gfm
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.6.0]
stages: [manual] # Manual because already done by mdformat-black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: end-of-file-fixer
- id: trailing-whitespace
- id: no-commit-to-branch
args: [--branch, main]
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: mixed-line-ending
- id: check-builtin-literals
- id: check-ast
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-docstring-first
- id: fix-byte-order-marker
- id: check-case-conflict
# - id: check-toml
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
rev: v1.32.0
hooks:
- id: yamllint
args:
Expand All @@ -69,17 +69,17 @@ repos:
hooks:
- id: shellcheck
files: ^[^\.].*\.sh$
# Change the entry to make this work on cygwin
args: [-x,-e,SC2086,-e,SC2004,-e,SC2207,-e,SC2002,-e,SC2116]
# add "shellcheck disable=SC2086" codes to files, rather than global excludes:
# args: [-x,-e,SC2086,-e,SC2004,-e,SC2207,-e,SC2002,-e,SC2116]
# args: ["--severity=warning"] # Optionally only show errors and warnings
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.11.0
hooks:
- id: pyupgrade
args:
- --py39-plus
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.9.1
hooks:
- id: black
args:
Expand All @@ -93,7 +93,7 @@ repos:
args: [--skip, 'B101,B311', --recursive, .]

- repo: https://github.com/fsouza/autoflake8
rev: v0.4.0
rev: v0.4.1
hooks:
- id: autoflake8
args:
Expand All @@ -102,7 +102,7 @@ repos:
- --expand-star-imports
- custom_components
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -118,7 +118,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.5
hooks:
- id: codespell
args:
Expand All @@ -138,7 +138,7 @@ repos:
#- homeassistant-stubs>=2023.1.7
# exclude: ^$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.5.1
hooks:
- id: mypy
args:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/zha_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
LOGGER = logging.getLogger(__name__)

try:
LOADED_VERSION
LOADED_VERSION # type:ignore[used-before-def]
except NameError:
LOADED_VERSION = ""

try:
DEFAULT_OTAU
DEFAULT_OTAU # type:ignore[used-before-def]
except NameError:
DEFAULT_OTAU = "/config/zigpy_ota"

Expand Down
1 change: 0 additions & 1 deletion custom_components/zha_toolkit/binds.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
async def bind_group(
app, listener, ieee, cmd, data, service, params, event_data
):

LOGGER.debug("running 'bind group' command: %s", service)
if ieee is None:
LOGGER.error("missing ieee")
Expand Down
1 change: 0 additions & 1 deletion custom_components/zha_toolkit/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ async def rejoin(app, listener, ieee, cmd, data, service, params, event_data):
async def misc_settime(
app, listener, ieee, cmd, data, service, params, event_data
):

from bisect import bisect
from datetime import datetime

Expand Down
1 change: 1 addition & 0 deletions custom_components/zha_toolkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ def wrapper(*args, tries=tries, delay=delay, **kwargs):

# zigpy wrappers


# The zigpy library does not offer retryable on read_attributes.
# Add it ourselves
@retryable(
Expand Down
1 change: 0 additions & 1 deletion custom_components/zha_toolkit/zcl_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ async def attr_write( # noqa: C901
)
and cmd == "attr_write"
):

if result_read is not None:
event_data["read_before"] = result_read
result_read = None
Expand Down
1 change: 0 additions & 1 deletion custom_components/zha_toolkit/zcl_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ async def zcl_cmd(app, listener, ieee, cmd, data, service, params, event_data):
False,
)
elif cmd_id not in cluster.server_commands:

cmd_schema: list[Any] = []

if cmd_args is not None:
Expand Down
2 changes: 0 additions & 2 deletions custom_components/zha_toolkit/zdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ async def zdo_scan_now(
async def zdo_flood_parent_annce(
app, listener, ieee, cmd, data, service, params, event_data
):

LOGGER.debug("flooding network with parent annce")

flooder_task = getattr(app, "flooder_task", None)
Expand All @@ -155,7 +154,6 @@ async def zdo_flood_parent_annce(


async def _flood_with_parent_annce(app):

coord = app.get_device(app.ieee)

while True:
Expand Down
1 change: 0 additions & 1 deletion custom_components/zha_toolkit/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async def zha_devices(
pass

if doGenerateCSV or selectDeviceFields:

if doGenerateCSV:
# Write CSV header
u.append_to_csvfile(
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.yamlfix]
# allow_duplicate_keys = true
#line_length = 280
line_length = 80
# none_representation = "null"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ max-line-length = 79

[codespell]
builtin=clear,rare,informal,usage,code,names
ignore-words-list=hass,master
ignore-words-list=hass,master,weerd
skip=./.*
quiet-level=2

Expand Down

0 comments on commit 3a76f59

Please sign in to comment.