mirror of
https://github.com/esphome/esphome.git
synced 2026-09-21 12:08:38 +00:00
[core] Enable ruff PIE (flake8-pie) lint family (#16658)
This commit is contained in:
@@ -84,12 +84,7 @@ def indent_list(text: str, padding: str = " ") -> list[str]:
|
||||
"""Indent each line of the given text with the specified padding."""
|
||||
lines = []
|
||||
for line in text.splitlines():
|
||||
if (
|
||||
line == ""
|
||||
or line.startswith("#ifdef")
|
||||
or line.startswith("#if ")
|
||||
or line.startswith("#endif")
|
||||
):
|
||||
if line == "" or line.startswith(("#ifdef", "#if ", "#endif")):
|
||||
p = ""
|
||||
else:
|
||||
p = padding
|
||||
|
||||
@@ -483,9 +483,7 @@ def should_run_device_builder(branch: str | None = None) -> bool:
|
||||
True if the device-builder downstream tests should run, False otherwise.
|
||||
"""
|
||||
target_branch = get_target_branch()
|
||||
if target_branch and (
|
||||
target_branch.startswith("release") or target_branch.startswith("beta")
|
||||
):
|
||||
if target_branch and (target_branch.startswith(("release", "beta"))):
|
||||
return False
|
||||
|
||||
for file in changed_files(branch):
|
||||
@@ -955,9 +953,7 @@ def detect_memory_impact_config(
|
||||
# all components at once would produce nonsensical memory impact results.
|
||||
# Memory impact analysis is most useful for focused PRs targeting dev.
|
||||
target_branch = get_target_branch()
|
||||
if target_branch and (
|
||||
target_branch.startswith("release") or target_branch.startswith("beta")
|
||||
):
|
||||
if target_branch and (target_branch.startswith(("release", "beta"))):
|
||||
print(
|
||||
f"Memory impact: Skipping analysis for target branch {target_branch} "
|
||||
f"(would try to build all components at once, giving nonsensical results)",
|
||||
@@ -1311,7 +1307,7 @@ def main() -> None:
|
||||
# (no isolation, all components are groupable)
|
||||
target_branch = get_target_branch()
|
||||
is_release_branch = target_branch and (
|
||||
target_branch.startswith("release") or target_branch.startswith("beta")
|
||||
target_branch.startswith(("release", "beta"))
|
||||
)
|
||||
|
||||
if is_release_branch:
|
||||
|
||||
+2
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user