From d7c5cd0a686b099bb361eb2b72c2aec8921161bc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 30 Aug 2026 21:11:23 -0500 Subject: [PATCH] Add type hints to the log literal lint --- script/ci-custom.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/ci-custom.py b/script/ci-custom.py index 24214ac3c4..8a9f972dda 100755 --- a/script/ci-custom.py +++ b/script/ci-custom.py @@ -3,6 +3,7 @@ import argparse import codecs import collections +from collections.abc import Iterator import fnmatch import functools import os.path @@ -1007,7 +1008,7 @@ def lint_log_multiline_continuation(fname, content): return errs -def _find_ternary_literals(text: str): +def _find_ternary_literals(text: str) -> Iterator[int]: """Yield the start offset of every string literal that is a ternary branch, i.e. whose previous non-space character outside a string literal is ``?`` or ``:``.""" prev = "" @@ -1033,7 +1034,9 @@ def _find_ternary_literals(text: str): @lint_content_check(include=cpp_include, exclude=["esphome/core/log.h"]) -def lint_log_no_bare_literal_ternary(fname, content): +def lint_log_no_bare_literal_ternary( + fname: Path, content: str +) -> list[tuple[int, int, str]]: errs = [] for log_match in LOG_MULTILINE_RE.finditer(content): for offset in _find_ternary_literals(log_match.group(0)):