mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 11:07:33 +00:00
[core] Enable ruff PGH (pygrep-hooks) lint family (#16651)
This commit is contained in:
@@ -56,7 +56,7 @@ from esphome.types import ConfigType
|
||||
from esphome.writer import clean_build, clean_cmake_cache
|
||||
|
||||
from .boards import BOARDS, STANDARD_BOARDS
|
||||
from .const import ( # noqa
|
||||
from .const import (
|
||||
KEY_ARDUINO_LIBRARIES,
|
||||
KEY_BOARD,
|
||||
KEY_COMPONENTS,
|
||||
@@ -86,7 +86,7 @@ from .const import ( # noqa
|
||||
)
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import esp32_pin_to_code # noqa
|
||||
from .gpio import esp32_pin_to_code # noqa: F401
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
AUTO_LOAD = ["preferences"]
|
||||
|
||||
@@ -14,7 +14,7 @@ from esphome.core import CORE
|
||||
from .const import KEY_HOST
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import host_pin_to_code # noqa
|
||||
from .gpio import host_pin_to_code # noqa: F401
|
||||
|
||||
CODEOWNERS = ["@esphome/core", "@clydebarrow"]
|
||||
AUTO_LOAD = ["network", "preferences"]
|
||||
|
||||
@@ -28,7 +28,7 @@ from esphome.core.config import BOARD_MAX_LENGTH
|
||||
from esphome.helpers import copy_file_if_changed
|
||||
from esphome.storage_json import StorageJSON
|
||||
|
||||
from . import gpio # noqa
|
||||
from . import gpio # noqa: F401
|
||||
from .const import (
|
||||
COMPONENT_BK72XX,
|
||||
CONF_GPIO_RECOVER,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright (c) Kuba Szczodrzyński 2023-06-01.
|
||||
|
||||
# pylint: skip-file
|
||||
# flake8: noqa
|
||||
# ruff: noqa: C408, I001
|
||||
|
||||
import json
|
||||
import re
|
||||
@@ -313,8 +313,12 @@ def write_const(
|
||||
# build component constants
|
||||
comp_str = "\n".join(f'COMPONENT_{f} = "{f.lower()}"' for f in components)
|
||||
# replace the 2nd regex group only
|
||||
repl = lambda m: m.group(1) + comp_str + m.group(3)
|
||||
code = re.sub(comp_regex, repl, code, flags=re.DOTALL | re.MULTILINE)
|
||||
code = re.sub(
|
||||
comp_regex,
|
||||
lambda m: m.group(1) + comp_str + m.group(3),
|
||||
code,
|
||||
flags=re.DOTALL | re.MULTILINE,
|
||||
)
|
||||
|
||||
# regex for finding the family list block
|
||||
fam_regex = r"(# FAMILIES.+?\n)(.*?)(\n# FAMILIES)"
|
||||
@@ -337,8 +341,12 @@ def write_const(
|
||||
]
|
||||
var_str = "\n".join(fam_lines)
|
||||
# replace the 2nd regex group only
|
||||
repl = lambda m: m.group(1) + var_str + m.group(3)
|
||||
code = re.sub(fam_regex, repl, code, flags=re.DOTALL | re.MULTILINE)
|
||||
code = re.sub(
|
||||
fam_regex,
|
||||
lambda m: m.group(1) + var_str + m.group(3),
|
||||
code,
|
||||
flags=re.DOTALL | re.MULTILINE,
|
||||
)
|
||||
|
||||
# format with black
|
||||
code = format_str(code, mode=FileMode())
|
||||
|
||||
@@ -58,7 +58,7 @@ from .effects import (
|
||||
RGB_EFFECTS,
|
||||
validate_effects,
|
||||
)
|
||||
from .types import ( # noqa
|
||||
from .types import ( # noqa: F401
|
||||
AddressableLight,
|
||||
AddressableLightState,
|
||||
ColorMode,
|
||||
|
||||
@@ -514,7 +514,7 @@ def validate_printf(value):
|
||||
(?:hh|h|ll|l|j|z|t|L|w|I|I32|I64)? # size
|
||||
[cCdiouxXeEfgGaAnpsSZ] # type
|
||||
)
|
||||
""" # noqa
|
||||
"""
|
||||
matches = re.findall(cfmt, value[CONF_FORMAT], flags=re.VERBOSE)
|
||||
if len(matches) != len(value[CONF_ARGS]):
|
||||
raise cv.Invalid(
|
||||
|
||||
@@ -6,7 +6,6 @@ from esphome.const import CONF_ARGS, CONF_FORMAT
|
||||
CONF_IF_NAN = "if_nan"
|
||||
|
||||
|
||||
# noqa
|
||||
f_regex = re.compile(
|
||||
r"""
|
||||
( # start of capture group 1
|
||||
@@ -20,7 +19,6 @@ f_regex = re.compile(
|
||||
""",
|
||||
flags=re.VERBOSE,
|
||||
)
|
||||
# noqa
|
||||
c_regex = re.compile(
|
||||
r"""
|
||||
( # start of capture group 1
|
||||
|
||||
@@ -65,7 +65,7 @@ from .const import (
|
||||
)
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import nrf52_pin_to_code # noqa
|
||||
from .gpio import nrf52_pin_to_code # noqa: F401
|
||||
|
||||
CODEOWNERS = ["@tomaszduda23"]
|
||||
AUTO_LOAD = ["zephyr", "preferences"]
|
||||
|
||||
@@ -50,7 +50,7 @@ from .const import (
|
||||
)
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import rp2040_pin_to_code # noqa
|
||||
from .gpio import rp2040_pin_to_code # noqa: F401
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
CODEOWNERS = ["@jesserockz"]
|
||||
|
||||
@@ -127,6 +127,7 @@ select = [
|
||||
"LOG", # flake8-logging
|
||||
"NPY", # numpy-specific rules
|
||||
"PERF", # performance
|
||||
"PGH", # pygrep-hooks
|
||||
"PIE", # flake8-pie
|
||||
"PL", # pylint
|
||||
"PTH", # flake8-use-pathlib
|
||||
|
||||
Reference in New Issue
Block a user