mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:53:26 +00:00
[core] Enable ruff B (flake8-bugbear) lint family (#16655)
This commit is contained in:
@@ -3551,7 +3551,7 @@ static const char *const TAG = "api.service";
|
||||
if id_ is not None and not mt.options.deprecated:
|
||||
id_to_msg_name[id_] = mt.name
|
||||
|
||||
for id_, (_, _, case_label) in cases:
|
||||
for id_, (_, _, _case_label) in cases:
|
||||
msg_name = id_to_msg_name.get(id_, "")
|
||||
if msg_name in message_auth_map:
|
||||
needs_auth = message_auth_map[msg_name]
|
||||
@@ -3614,7 +3614,7 @@ static const char *const TAG = "api.service";
|
||||
|
||||
# Dispatch switch
|
||||
out += " switch (msg_type) {\n"
|
||||
for i, (case, ifdef, case_label) in cases:
|
||||
for _i, (case, ifdef, case_label) in cases:
|
||||
if ifdef is not None:
|
||||
out += _make_ifdef_line(ifdef) + "\n"
|
||||
|
||||
|
||||
@@ -972,7 +972,7 @@ def convert(schema, config_var, path):
|
||||
}
|
||||
elif schema_type == "use_id":
|
||||
if inspect.ismodule(data):
|
||||
m_attr_obj = getattr(data, "CONFIG_SCHEMA")
|
||||
m_attr_obj = data.CONFIG_SCHEMA
|
||||
use_schema = known_schemas.get(repr(m_attr_obj))
|
||||
if use_schema:
|
||||
[output_module, output_name] = use_schema[0][1].split(".")
|
||||
|
||||
@@ -342,8 +342,8 @@ def lint_const_ordered(fname, content):
|
||||
(i + 1, line) for i, line in enumerate(lines) if line.startswith(start)
|
||||
]
|
||||
ordered = sorted(matching, key=lambda x: x[1].replace("_", " "))
|
||||
ordered = [(mi, ol) for (mi, _), (_, ol) in zip(matching, ordered)]
|
||||
for (mi, mline), (_, ol) in zip(matching, ordered):
|
||||
ordered = [(mi, ol) for (mi, _), (_, ol) in zip(matching, ordered, strict=True)]
|
||||
for (mi, mline), (_, ol) in zip(matching, ordered, strict=True):
|
||||
if mline == ol:
|
||||
continue
|
||||
target = next(i for i, line in ordered if line == mline)
|
||||
|
||||
@@ -1047,7 +1047,7 @@ def detect_memory_impact_config(
|
||||
# Find common platforms supported by ALL components
|
||||
# This ensures we can build all components together in a merged config
|
||||
common_platforms = set(MEMORY_IMPACT_PLATFORM_PREFERENCE)
|
||||
for component, platforms in component_platforms_map.items():
|
||||
for platforms in component_platforms_map.values():
|
||||
common_platforms &= platforms
|
||||
|
||||
# Select the most preferred platform from the common set
|
||||
|
||||
@@ -295,7 +295,7 @@ def main() -> int:
|
||||
# Sort groups by signature for readability
|
||||
groupable_groups = []
|
||||
isolated_groups = []
|
||||
for (platform, signature), group_comps in sorted(signature_groups.items()):
|
||||
for (_platform, signature), group_comps in sorted(signature_groups.items()):
|
||||
if signature.startswith(ISOLATED_SIGNATURE_PREFIX):
|
||||
isolated_groups.append((signature, group_comps))
|
||||
else:
|
||||
|
||||
@@ -890,7 +890,7 @@ def run_grouped_component_tests(
|
||||
print("=" * 80 + "\n")
|
||||
|
||||
# Execute grouped tests
|
||||
for (platform, signature), components in grouped_components.items():
|
||||
for (platform, _signature), components in grouped_components.items():
|
||||
# Only group if we have multiple components with same signature
|
||||
if len(components) <= 1:
|
||||
continue
|
||||
@@ -1055,7 +1055,7 @@ def test_components(
|
||||
|
||||
# Create empty test files for each platform (or filtered platform)
|
||||
reference_tests: list[Path] = []
|
||||
for platform_name, base_file in platform_bases.items():
|
||||
for platform_name in platform_bases:
|
||||
if platform_filter and not platform_name.startswith(platform_filter):
|
||||
continue
|
||||
# Create an empty test file named to match the platform
|
||||
|
||||
Reference in New Issue
Block a user