mirror of
https://github.com/esphome/esphome.git
synced 2026-09-24 21:44:04 +00:00
[core] Enable ruff BLE (flake8-blind-except) lint family (#16659)
This commit is contained in:
@@ -128,7 +128,7 @@ def uses_local_file_references(component_dir: Path) -> bool:
|
||||
|
||||
try:
|
||||
content = common_yaml.read_text()
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
except Exception: # noqa: BLE001 # pylint: disable=broad-exception-caught
|
||||
return False
|
||||
|
||||
# Pattern to match $component_dir or ${component_dir} references
|
||||
@@ -164,7 +164,7 @@ def is_platform_component(component_dir: Path) -> bool:
|
||||
try:
|
||||
content = comp_init.read_text()
|
||||
return "IS_PLATFORM_COMPONENT = True" in content
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
except Exception: # noqa: BLE001 # pylint: disable=broad-exception-caught
|
||||
return False
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ def analyze_yaml_file(yaml_file: Path) -> dict[str, Any]:
|
||||
try:
|
||||
data = yaml_util.load_yaml(yaml_file)
|
||||
result["loaded"] = True
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
except Exception: # noqa: BLE001 # pylint: disable=broad-exception-caught
|
||||
return result
|
||||
|
||||
# Check for Extend/Remove objects
|
||||
|
||||
@@ -392,7 +392,7 @@ def compile_and_get_binary(
|
||||
if exit_code != 0:
|
||||
print(f"Error compiling {label} for {', '.join(components)}")
|
||||
return exit_code, None
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Error compiling {label} for {', '.join(components)}: {e}")
|
||||
return EXIT_COMPILE_ERROR, None
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ def _is_clang_tidy_full_scan() -> bool:
|
||||
)
|
||||
# Exit 0 means hash changed (full scan needed)
|
||||
return result.returncode == 0
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001
|
||||
# If hash check fails, run full scan to be safe
|
||||
return True
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ def main() -> None:
|
||||
tests_dir=args.tests_dir,
|
||||
output_file=args.output,
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Error merging configs: {e}", file=sys.stderr)
|
||||
import traceback
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ async def connect_disconnect(client_id: int, iteration: int) -> tuple[int, bool,
|
||||
await asyncio.wait_for(cli.connect(login=True), timeout=10)
|
||||
await cli.disconnect()
|
||||
return iteration, True, ""
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001
|
||||
return (
|
||||
iteration,
|
||||
False,
|
||||
|
||||
@@ -63,7 +63,7 @@ def test_component_group(
|
||||
try:
|
||||
result = subprocess.run(cmd, check=False)
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Error running test: {e}")
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user