Enable even more SIM ruff rules (#113017)

* SIM202 SIM211 SIM220 SIM221 SIM222 SIM223

* SIM910 SIM911

* SIM

* Update homeassistant/components/mqtt/siren.py

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

* Update homeassistant/components/mqtt/siren.py

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
Joost Lekkerkerker 2024-03-11 14:23:52 +01:00 committed by GitHub
parent 48cb09a4a8
commit 2792a5f016
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 20 additions and 38 deletions

View file

@ -118,8 +118,8 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
data_type = config[CONF_DATA_TYPE]
if data_type == "int":
data_type = config[CONF_DATA_TYPE] = DataType.INT16
count = config.get(CONF_COUNT, None)
structure = config.get(CONF_STRUCTURE, None)
count = config.get(CONF_COUNT)
structure = config.get(CONF_STRUCTURE)
slave_count = config.get(CONF_SLAVE_COUNT, config.get(CONF_VIRTUAL_COUNT))
validator = DEFAULT_STRUCT_FORMAT[data_type].validate_parm
swap_type = config.get(CONF_SWAP)
@ -148,6 +148,8 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
raise vol.Invalid(error)
if config[CONF_DATA_TYPE] == DataType.CUSTOM:
assert isinstance(structure, str)
assert isinstance(count, int)
try:
size = struct.calcsize(structure)
except struct.error as err:
@ -332,7 +334,7 @@ def check_config(config: dict) -> dict:
):
if conf_type in entity:
addr += f"_{entity[conf_type]}"
inx = entity.get(CONF_SLAVE, None) or entity.get(CONF_DEVICE_ADDRESS, 0)
inx = entity.get(CONF_SLAVE) or entity.get(CONF_DEVICE_ADDRESS, 0)
addr += f"_{inx}"
loc_addr: set[str] = {addr}