mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
Improve loops and lists (#113269)
* Enable PERF * Enable PERF rule * Enable PERF rule * Don't enable flag yet
This commit is contained in:
committed by
GitHub
parent
8a98fb7cfd
commit
05172d8e4d
@@ -347,8 +347,7 @@ def generate_requirements_list(reqs: dict[str, list[str]]) -> str:
|
||||
"""Generate a pip file based on requirements."""
|
||||
output = []
|
||||
for pkg, requirements in sorted(reqs.items(), key=itemgetter(0)):
|
||||
for req in sorted(requirements):
|
||||
output.append(f"\n# {req}")
|
||||
output.extend(f"\n# {req}" for req in sorted(requirements))
|
||||
|
||||
if comment_requirement(pkg):
|
||||
output.append(f"\n# {pkg}\n")
|
||||
|
||||
@@ -16,8 +16,7 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str:
|
||||
if not match_types:
|
||||
continue
|
||||
|
||||
for entry in match_types:
|
||||
match_list.append({"domain": domain, **entry})
|
||||
match_list.extend({"domain": domain, **entry} for entry in match_types)
|
||||
|
||||
return format_python_namespace(
|
||||
{"BLUETOOTH": match_list},
|
||||
|
||||
@@ -16,8 +16,7 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str:
|
||||
if not match_types:
|
||||
continue
|
||||
|
||||
for entry in match_types:
|
||||
match_list.append({"domain": domain, **entry})
|
||||
match_list.extend({"domain": domain, **entry} for entry in match_types)
|
||||
|
||||
return format_python_namespace(
|
||||
{"DHCP": match_list},
|
||||
|
||||
@@ -16,13 +16,13 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str:
|
||||
if not match_types:
|
||||
continue
|
||||
|
||||
for entry in match_types:
|
||||
match_list.append(
|
||||
{
|
||||
"domain": domain,
|
||||
**{k: v for k, v in entry.items() if k != "known_devices"},
|
||||
}
|
||||
)
|
||||
match_list.extend(
|
||||
{
|
||||
"domain": domain,
|
||||
**{k: v for k, v in entry.items() if k != "known_devices"},
|
||||
}
|
||||
for entry in match_types
|
||||
)
|
||||
|
||||
return format_python_namespace({"USB": match_list})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user