Apply build fixes, black, flake8, pylint, and ci-custom recommendation

This commit is contained in:
Michael Davidson 2024-01-03 12:48:28 +11:00
parent 0403562e3a
commit 130ce44c51
No known key found for this signature in database
GPG Key ID: B8D1A99712B8B0EB
4 changed files with 17 additions and 25 deletions

View File

@ -31,9 +31,7 @@ void TextPanel::dump_config(int indent_depth, int additional_level_depth) {
void TextPanel::setup_complete() {
if (!this->text_formatter_.has_value()) {
this->text_formatter_ = [this](const std::string string) {
return string;
};
this->text_formatter_ = [this](const std::string string) { return string; };
}
if (this->sensor_ != nullptr) {
@ -47,15 +45,11 @@ void TextPanel::setup_complete() {
if (this->text_sensor_ != nullptr) {
// Need to setup the text callback to the TextSensor
this->text_ = [this]() {
return this->text_formatter_.value(this->text_sensor_->get_state());
};
this->text_ = [this]() { return this->text_formatter_.value(this->text_sensor_->get_state()); };
}
if (this->text_input_.has_value()) {
this->text_ = [this]() {
return this->text_formatter_.value(this->text_input_.value());
};
this->text_ = [this]() { return this->text_formatter_.value(this->text_input_.value()); };
}
}

View File

@ -2,7 +2,7 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import font, color, sensor, text_sensor
from esphome.components.display import display_ns
from esphome.const import CONF_FOREGROUND_COLOR, CONF_BACKGROUND_COLOR, CONST_SENSOR
from esphome.const import CONF_FOREGROUND_COLOR, CONF_BACKGROUND_COLOR, CONF_SENSOR
graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout")
TextPanel = graphical_layout_ns.class_("TextPanel")

View File

@ -31,15 +31,13 @@ struct CanWrapAtCharacterArguments {
class TextRunBase {
public:
TextRunBase(display::BaseFont *font) {
this->font_ = font;
}
TextRunBase(display::BaseFont *font) { this->font_ = font; }
void set_foreground_color(Color foreground_color) { this->foreground_color_ = foreground_color; }
void set_background_color(Color background_color) { this->background_color_ = background_color; }
virtual std::string get_text() = 0;
display::BaseFont *font_{nullptr};
Color foreground_color_{COLOR_ON};
Color background_color_{COLOR_OFF};
@ -67,9 +65,7 @@ class TextRun : public TextRunBase, public FormattableTextRun {
this->text_ = std::move(text);
}
std::string get_text() override {
return this->format_text(text_.value());
}
std::string get_text() override { return this->format_text(text_.value()); }
protected:
TemplatableValue<std::string> text_{};
@ -77,9 +73,7 @@ class TextRun : public TextRunBase, public FormattableTextRun {
class SensorTextRun : public TextRunBase, public FormattableTextRun {
public:
SensorTextRun(sensor::Sensor *sensor, display::BaseFont *font) : TextRunBase(font) {
this->sensor_ = sensor;
}
SensorTextRun(sensor::Sensor *sensor, display::BaseFont *font) : TextRunBase(font) { this->sensor_ = sensor; }
std::string get_text() override {
std::stringstream stream;
@ -97,9 +91,8 @@ class TextSensorTextRun : public TextRunBase, public FormattableTextRun {
this->text_sensor_ = text_sensor;
}
std::string get_text() override {
return this->format_text(this->text_sensor_->get_state());
}
std::string get_text() override { return this->format_text(this->text_sensor_->get_state()); }
protected:
text_sensor::TextSensor *text_sensor_{nullptr};

View File

@ -2,7 +2,12 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import font, color, sensor, text_sensor
from esphome.components.display import display_ns
from esphome.const import CONF_ID, CONF_FOREGROUND_COLOR, CONF_BACKGROUND_COLOR, CONF_SENSOR
from esphome.const import (
CONF_ID,
CONF_FOREGROUND_COLOR,
CONF_BACKGROUND_COLOR,
CONF_SENSOR,
)
graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout")
TextRunPanel = graphical_layout_ns.class_("TextRunPanel")