Housecleaning: Use walrus operator in text (#6560)

This commit is contained in:
Jesse Hills 2024-04-17 18:22:52 +12:00 committed by GitHub
parent 717cea548f
commit 2fc2d5839f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,8 +73,8 @@ async def setup_text_core_(
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [(cg.std_string, "x")], conf)
if CONF_MQTT_ID in config:
mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], var)
if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)