[core] Enable ruff PIE (flake8-pie) lint family (#16658)

This commit is contained in:
J. Nick Koston
2026-05-26 06:46:44 -05:00
committed by GitHub
parent 8b62cfded7
commit ceb9d406e1
15 changed files with 25 additions and 33 deletions

View File

@@ -103,9 +103,7 @@ def get_component_from_path(file_path: str) -> str | None:
Returns:
Component name if path is in components or tests directory, None otherwise
"""
if file_path.startswith(ESPHOME_COMPONENTS_PATH) or file_path.startswith(
ESPHOME_TESTS_COMPONENTS_PATH
):
if file_path.startswith((ESPHOME_COMPONENTS_PATH, ESPHOME_TESTS_COMPONENTS_PATH)):
parts = file_path.split("/")
if len(parts) >= 3 and parts[2]:
# Verify that parts[2] is actually a component directory, not a file
@@ -160,7 +158,7 @@ def is_validate_only_file(test_file: Path) -> bool:
``esphome config`` only and skipped during compile.
"""
name = test_file.name
return name.startswith("validate.") or name.startswith("validate-")
return name.startswith(("validate.", "validate-"))
@dataclass(frozen=True)