mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 03:12:20 +01:00
[ruff] Enable RET and fix all violations (#9929)
This commit is contained in:
@@ -31,8 +31,7 @@ class DashboardTestHelper:
|
||||
else:
|
||||
url = f"http://127.0.0.1:{self.port}{path}"
|
||||
future = self.client.fetch(url, raise_error=True, **kwargs)
|
||||
result = await future
|
||||
return result
|
||||
return await future
|
||||
|
||||
|
||||
@pytest_asyncio.fixture()
|
||||
|
@@ -251,19 +251,18 @@ async def compile_esphome(
|
||||
if proc.returncode == 0:
|
||||
# Success!
|
||||
break
|
||||
elif proc.returncode == -11 and attempt < max_retries - 1:
|
||||
if proc.returncode == -11 and attempt < max_retries - 1:
|
||||
# Segfault (-11 = SIGSEGV), retry
|
||||
print(
|
||||
f"Compilation segfaulted (attempt {attempt + 1}/{max_retries}), retrying..."
|
||||
)
|
||||
await asyncio.sleep(1) # Brief pause before retry
|
||||
continue
|
||||
else:
|
||||
# Other error or final retry
|
||||
raise RuntimeError(
|
||||
f"Failed to compile {config_path}, return code: {proc.returncode}. "
|
||||
f"Run with 'pytest -s' to see compilation output."
|
||||
)
|
||||
# Other error or final retry
|
||||
raise RuntimeError(
|
||||
f"Failed to compile {config_path}, return code: {proc.returncode}. "
|
||||
f"Run with 'pytest -s' to see compilation output."
|
||||
)
|
||||
|
||||
# Load the config to get idedata (blocking call, must use executor)
|
||||
loop = asyncio.get_running_loop()
|
||||
|
@@ -72,8 +72,7 @@ DisableAction = loop_test_component_ns.class_("DisableAction", automation.Action
|
||||
)
|
||||
async def enable_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, parent)
|
||||
return var
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
@@ -87,8 +86,7 @@ async def enable_to_code(config, action_id, template_arg, args):
|
||||
)
|
||||
async def disable_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, parent)
|
||||
return var
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
|
@@ -69,7 +69,7 @@ def test_calculate_clang_tidy_hash() -> None:
|
||||
def read_file_mock(path: Path) -> bytes:
|
||||
if ".clang-tidy" in str(path):
|
||||
return clang_tidy_content
|
||||
elif "platformio.ini" in str(path):
|
||||
if "platformio.ini" in str(path):
|
||||
return platformio_content
|
||||
return b""
|
||||
|
||||
|
@@ -315,9 +315,8 @@ def test_local_development_no_remotes_configured(monkeypatch: MonkeyPatch) -> No
|
||||
def side_effect_func(*args):
|
||||
if args == ("git", "remote"):
|
||||
return "origin\nupstream\n"
|
||||
else:
|
||||
# All merge-base attempts fail
|
||||
raise Exception("Command failed")
|
||||
# All merge-base attempts fail
|
||||
raise Exception("Command failed")
|
||||
|
||||
mock_output.side_effect = side_effect_func
|
||||
|
||||
|
@@ -18,11 +18,10 @@ def sort_dicts(obj):
|
||||
"""Recursively sort dictionaries for order-insensitive comparison."""
|
||||
if isinstance(obj, dict):
|
||||
return {k: sort_dicts(obj[k]) for k in sorted(obj)}
|
||||
elif isinstance(obj, list):
|
||||
if isinstance(obj, list):
|
||||
# Lists are not sorted; we preserve order
|
||||
return [sort_dicts(i) for i in obj]
|
||||
else:
|
||||
return obj
|
||||
return obj
|
||||
|
||||
|
||||
def dict_diff(a, b, path=""):
|
||||
|
@@ -22,8 +22,7 @@ def _run_repl_test(input_data):
|
||||
call[0][0] for call in mock_stdout.write.call_args_list
|
||||
).strip()
|
||||
splitted_output = full_output.split("\n")
|
||||
remove_version = splitted_output[1:] # remove first entry with version info
|
||||
return remove_version
|
||||
return splitted_output[1:] # remove first entry with version info
|
||||
|
||||
|
||||
def _validate(file_path: str):
|
||||
|
Reference in New Issue
Block a user