[core] Enable ruff G (flake8-logging-format) lint family (#16650)

This commit is contained in:
J. Nick Koston
2026-05-25 20:36:49 -05:00
committed by GitHub
parent e492f8f8b6
commit dd0028c1b5
5 changed files with 7 additions and 5 deletions

View File

@@ -96,7 +96,7 @@ def _extract_tz_string(tzfile: bytes) -> str:
return tzfile.split(b"\n")[-2].decode() return tzfile.split(b"\n")[-2].decode()
except (IndexError, UnicodeDecodeError): except (IndexError, UnicodeDecodeError):
_LOGGER.error("Could not determine TZ string. Please report this issue.") _LOGGER.error("Could not determine TZ string. Please report this issue.")
_LOGGER.error("tzfile contents: %s", tzfile, exc_info=True) _LOGGER.exception("tzfile contents: %s", tzfile)
raise raise

View File

@@ -239,12 +239,12 @@ def _lookup_module(domain: str, exception: bool) -> ComponentManifest | None:
"Unable to import component %s: %s", domain, str(e), exc_info=False "Unable to import component %s: %s", domain, str(e), exc_info=False
) )
else: else:
_LOGGER.error("Unable to import component %s:", domain, exc_info=True) _LOGGER.exception("Unable to import component %s:", domain)
return None return None
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
if exception: if exception:
raise raise
_LOGGER.error("Unable to load component %s:", domain, exc_info=True) _LOGGER.exception("Unable to load component %s:", domain)
return None return None
manif = ComponentManifest(module) manif = ComponentManifest(module)

View File

@@ -272,9 +272,10 @@ def check_strapping_pin(conf, strapping_pin_list: set[int], logger: Logger):
num = conf[CONF_NUMBER] num = conf[CONF_NUMBER]
if num in strapping_pin_list and not conf.get(CONF_IGNORE_STRAPPING_WARNING): if num in strapping_pin_list and not conf.get(CONF_IGNORE_STRAPPING_WARNING):
logger.warning( logger.warning(
f"GPIO{num} is a strapping PIN and should only be used for I/O with care.\n" "GPIO%s is a strapping PIN and should only be used for I/O with care.\n"
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n" "Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n"
"See https://esphome.io/guides/faq/#why-am-i-getting-a-warning-about-strapping-pins", "See https://esphome.io/guides/faq/#why-am-i-getting-a-warning-about-strapping-pins",
num,
) )
# mitigate undisciplined use of strapping: # mitigate undisciplined use of strapping:
if num not in strapping_pin_list and conf.get(CONF_IGNORE_STRAPPING_WARNING): if num not in strapping_pin_list and conf.get(CONF_IGNORE_STRAPPING_WARNING):

View File

@@ -96,7 +96,7 @@ def _run_idedata(config):
try: try:
return json.loads(match.group()) return json.loads(match.group())
except ValueError: except ValueError:
_LOGGER.error("Could not parse idedata", exc_info=True) _LOGGER.exception("Could not parse idedata")
_LOGGER.error("Stdout: %s", stdout) _LOGGER.error("Stdout: %s", stdout)
raise raise

View File

@@ -118,6 +118,7 @@ select = [
"FA", # flake8-future-annotations "FA", # flake8-future-annotations
"FLY", # flynt: convert string formatting to f-strings "FLY", # flynt: convert string formatting to f-strings
"FURB", # refurb "FURB", # refurb
"G", # flake8-logging-format
"I", # isort "I", # isort
"ICN", # flake8-import-conventions "ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat "ISC", # flake8-implicit-str-concat