Enable Ruff SIM105 (#86759)

* Enable Ruff SIM105

* Adjust existing cases
This commit is contained in:
Franck Nijhof 2023-01-27 03:06:22 +01:00 committed by GitHub
parent 71d7098530
commit e738924780
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 36 additions and 47 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
from collections.abc import Callable
from contextlib import suppress
import datetime as dt
import json
from typing import Any, cast
@ -262,11 +263,9 @@ def handle_get_states(
# If we can't serialize, we'll filter out unserializable states
serialized = []
for state in states:
try:
# Error is already logged above
with suppress(ValueError, TypeError):
serialized.append(JSON_DUMP(state))
except (ValueError, TypeError):
# Error is already logged above
pass
# We now have partially serialized states. Craft some JSON.
response2 = JSON_DUMP(messages.result_message(msg["id"], ["TO_REPLACE"]))