1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-23 08:50:09 +01:00

Enable ruff RUF051 rule and simplify dict key removal (#170523)

This commit is contained in:
Franck Nijhof
2026-05-13 23:18:52 +02:00
committed by GitHub
parent 1e8a9ded70
commit 1bf3bfc082
3 changed files with 7 additions and 11 deletions
+5 -9
View File
@@ -5158,7 +5158,7 @@ def _validate_pki_file(
return True
async def async_get_broker_settings( # noqa: C901
async def async_get_broker_settings(
flow: ConfigFlow | OptionsFlow,
fields: OrderedDict[Any, Any],
entry_config: MappingProxyType[str, Any] | None,
@@ -5284,15 +5284,11 @@ async def async_get_broker_settings( # noqa: C901
errors["base"] = error
return False
if SET_CA_CERT in validated_user_input:
del validated_user_input[SET_CA_CERT]
if SET_CLIENT_CERT in validated_user_input:
del validated_user_input[SET_CLIENT_CERT]
validated_user_input.pop(SET_CA_CERT, None)
validated_user_input.pop(SET_CLIENT_CERT, None)
if validated_user_input.get(CONF_TRANSPORT, TRANSPORT_TCP) == TRANSPORT_TCP:
if CONF_WS_PATH in validated_user_input:
del validated_user_input[CONF_WS_PATH]
if CONF_WS_HEADERS in validated_user_input:
del validated_user_input[CONF_WS_HEADERS]
validated_user_input.pop(CONF_WS_PATH, None)
validated_user_input.pop(CONF_WS_HEADERS, None)
return True
try:
validated_user_input[CONF_WS_HEADERS] = json_loads(
+1 -2
View File
@@ -1416,8 +1416,7 @@ async def async_get_integrations(
future.set_result(integration)
for domain in results:
if domain in needed:
del needed[domain]
needed.pop(domain, None)
# Now the rest use resolve_from_root
if needed:
+1
View File
@@ -735,6 +735,7 @@ select = [
"RUF032", # Decimal() called with float literal argument
"RUF033", # __post_init__ method with argument defaults
"RUF034", # Useless if-else condition
"RUF051", # Use dict.pop(key, None) instead of if-key-in-dict-del
"RUF059", # unused-unpacked-variable
"RUF100", # Unused `noqa` directive
"RUF101", # noqa directives that use redirected rule codes