Enable Ruff SIM212 (#88181)

This commit is contained in:
Franck Nijhof 2023-02-15 15:22:34 +01:00 committed by GitHub
parent 951269e88c
commit 793e51ac76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -106,7 +106,7 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = {
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
value=lambda prev, val: prev if not val else val, value=lambda prev, val: val if val else prev,
available=lambda entity: entity.coordinator.data is not None, available=lambda entity: entity.coordinator.data is not None,
), ),
"C": GoodweSensorEntityDescription( "C": GoodweSensorEntityDescription(

View File

@ -251,6 +251,7 @@ select = [
"SIM117", # Merge with-statements that use the same scope "SIM117", # Merge with-statements that use the same scope
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
"SIM201", # Use {left} != {right} instead of not {left} == {right} "SIM201", # Use {left} != {right} instead of not {left} == {right}
"SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a}
"SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'. "SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'.
"SIM401", # Use get from dict with default instead of an if block "SIM401", # Use get from dict with default instead of an if block
"T20", # flake8-print "T20", # flake8-print