[ci] Run pylint when its version, dependencies or configuration change (#20202)

This commit is contained in:
Bascht74
2026-10-05 21:20:28 -05:00
committed by GitHub
parent 6191b7553e
commit 718b6651fe
2 changed files with 24 additions and 8 deletions
+20 -8
View File
@@ -31,7 +31,7 @@ The CI workflow uses this information to:
- Skip or run integration tests
- Skip or run clang-tidy (and whether to do a full scan)
- Skip or run clang-format
- Skip or run Python linters (ruff, flake8, pylint, pyupgrade)
- Skip or run pylint
- Skip or run downstream esphome/device-builder tests against the PR's Python code
- Determine which components to test individually
- Decide how to split component tests (if there are many)
@@ -403,21 +403,33 @@ def should_run_clang_format(branch: str | None = None) -> bool:
return _any_changed_file_endswith(branch, CPP_FILE_EXTENSIONS)
# Linter pins, dependencies and linter config can change findings without a .py change.
PYTHON_LINTERS_TRIGGER_FILES = frozenset(
{
"requirements.txt",
"requirements_test.txt",
"pyproject.toml",
}
)
def should_run_python_linters(branch: str | None = None) -> bool:
"""Determine if Python linters (ruff, flake8, pylint, pyupgrade) should run based on changed files.
"""Determine if the pylint job should run based on changed files.
This function is used by the CI workflow to skip Python linting checks when no Python files
have changed, saving CI time and resources.
Python linters will run when any Python source files have changed.
The CI workflow skips pylint unless a Python file or a file in
PYTHON_LINTERS_TRIGGER_FILES has changed. ruff, flake8 and pyupgrade run in
lint-format, which this flag does not gate.
Args:
branch: Branch to compare against. If None, uses default.
Returns:
True if Python linters should run, False otherwise.
True if pylint should run, False otherwise.
"""
return _any_changed_file_endswith(branch, PYTHON_FILE_EXTENSIONS)
return any(
file.endswith(PYTHON_FILE_EXTENSIONS) or file in PYTHON_LINTERS_TRIGGER_FILES
for file in changed_files(branch)
)
# Files outside esphome/**/*.py whose changes can affect `import esphome.__main__`