From 98d0326f682021328ef7a873d94756131712c1fa Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 21 Oct 2024 13:21:54 +0200 Subject: [PATCH] Improve pre-commit hooks (#50) --- .pre-commit-config.yaml | 2 - components/votronic/__init__.py | 2 +- components/votronic/binary_sensor.py | 2 +- components/votronic/sensor.py | 2 +- components/votronic/text_sensor.py | 2 +- components/votronic_ble/__init__.py | 2 +- components/votronic_ble/binary_sensor.py | 2 +- components/votronic_ble/sensor.py | 2 +- components/votronic_ble/text_sensor.py | 2 +- setup.cfg | 58 ++++++++++++++++++++++++ 10 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 setup.cfg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1580f10..6ea3234 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,6 @@ repos: args: - --safe - --quiet - files: ^((components|esphome|script|tests)/.+)?[^/]+\.py$ - repo: https://github.com/PyCQA/flake8 rev: 7.1.0 hooks: @@ -30,7 +29,6 @@ repos: additional_dependencies: - flake8-docstrings==1.5.0 - pydocstyle==5.1.1 - files: ^(components|esphome|tests)/.+\.py$ - repo: https://github.com/asottile/pyupgrade rev: v3.17.0 hooks: diff --git a/components/votronic/__init__.py b/components/votronic/__init__.py index ca450af..14ff89d 100644 --- a/components/votronic/__init__.py +++ b/components/votronic/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_THROTTLE CODEOWNERS = ["@syssi"] diff --git a/components/votronic/binary_sensor.py b/components/votronic/binary_sensor.py index b3ba7e9..a937a21 100644 --- a/components/votronic/binary_sensor.py +++ b/components/votronic/binary_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_ICON, CONF_ID from . import CONF_VOTRONIC_ID, Votronic diff --git a/components/votronic/sensor.py b/components/votronic/sensor.py index ea273c9..4ea4732 100644 --- a/components/votronic/sensor.py +++ b/components/votronic/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BATTERY_VOLTAGE, CONF_CURRENT, diff --git a/components/votronic/text_sensor.py b/components/votronic/text_sensor.py index 66a13fb..e742458 100644 --- a/components/votronic/text_sensor.py +++ b/components/votronic/text_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_ICON, CONF_ID from . import CONF_VOTRONIC_ID, Votronic diff --git a/components/votronic_ble/__init__.py b/components/votronic_ble/__init__.py index 38136ab..c32a1a9 100644 --- a/components/votronic_ble/__init__.py +++ b/components/votronic_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import ble_client +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_THROTTLE AUTO_LOAD = ["sensor", "text_sensor"] diff --git a/components/votronic_ble/binary_sensor.py b/components/votronic_ble/binary_sensor.py index f127f7f..8d68374 100644 --- a/components/votronic_ble/binary_sensor.py +++ b/components/votronic_ble/binary_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_ICON, CONF_ID from . import CONF_VOTRONIC_BLE_ID, VotronicBle diff --git a/components/votronic_ble/sensor.py b/components/votronic_ble/sensor.py index 81bd1b9..84a54f4 100644 --- a/components/votronic_ble/sensor.py +++ b/components/votronic_ble/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BATTERY_VOLTAGE, CONF_CURRENT, diff --git a/components/votronic_ble/text_sensor.py b/components/votronic_ble/text_sensor.py index 01f3989..f7bafb2 100644 --- a/components/votronic_ble/text_sensor.py +++ b/components/votronic_ble/text_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_ICON, CONF_ID from . import CONF_VOTRONIC_BLE_ID, VotronicBle diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..1b35392 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,58 @@ +[flake8] +max-line-length = 120 +# Following 4 for black compatibility +# E501: line too long +# W503: Line break occurred before a binary operator +# E203: Whitespace before ':' +# D202 No blank lines allowed after function docstring + +# TODO fix flake8 +# D100 Missing docstring in public module +# D101 Missing docstring in public class +# D102 Missing docstring in public method +# D103 Missing docstring in public function +# D104 Missing docstring in public package +# D105 Missing docstring in magic method +# D107 Missing docstring in __init__ +# D200 One-line docstring should fit on one line with quotes +# D205 1 blank line required between summary line and description +# D209 Multi-line docstring closing quotes should be on a separate line +# D400 First line should end with a period +# D401 First line should be in imperative mood + +ignore = + E501, + W503, + E203, + D202, + + D100, + D101, + D102, + D103, + D104, + D105, + D107, + D200, + D205, + D209, + D400, + D401, + +[isort] +# https://github.com/timothycrosley/isort +# https://github.com/timothycrosley/isort/wiki/isort-Settings +# splits long import on multiple lines indented by 4 spaces +multi_line_output = 3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 +indent = " " +# will group `import x` and `from x import` of the same module. +force_sort_within_sections = true +sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +default_section = THIRDPARTY +known_first_party = custom_components,tests +forced_separate = tests +combine_as_imports = true