[core] Enable ruff PIE (flake8-pie) lint family (#16658)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2026-05-26 07:46:44 -04:00
1 parent 8b62cfded7
commit ceb9d406e1
15 files changed
+25 -33

No files matched your search

+1 -1
View File
@@ -100,7 +100,7 @@ def position(min=-MAX_POSITION, max=MAX_POSITION):
if isinstance(value, str) and value.endswith("%"):
value = percent_to_position(value)
if isinstance(value, str) and (value.endswith("°") or value.endswith("deg")):
if isinstance(value, str) and value.endswith(("°", "deg")):
return angle_to_position(
value,
min=round(min * POSITION_TO_ANGLE),
+1 -1
View File
@@ -72,7 +72,7 @@ def _file_schema(value: ConfigType | str) -> ConfigType:
def _validate_file_shorthand(value: str) -> ConfigType:
value = cv.string_strict(value)
if value.startswith("http://") or value.startswith("https://"):
if value.startswith(("http://", "https://")):
return _file_schema(
{
CONF_TYPE: TYPE_WEB,
+1 -1
View File
@@ -401,7 +401,7 @@ def validate_file_shorthand(value):
data[CONF_WEIGHT] = weight[1:]
return font_file_schema(data)
if value.startswith("http://") or value.startswith("https://"):
if value.startswith(("http://", "https://")):
return font_file_schema(
{
CONF_TYPE: TYPE_WEB,
+1 -1
View File
@@ -65,7 +65,7 @@ CONF_JSON = "json"
def validate_url(value):
value = cv.url(value)
if value.startswith("http://") or value.startswith("https://"):
if value.startswith(("http://", "https://")):
return value
raise cv.Invalid("URL must start with 'http://' or 'https://'")
+1 -1
View File
@@ -408,7 +408,7 @@ def validate_file_shorthand(value):
raise cv.Invalid(f"Could not parse mdi icon name from '{value}'.")
return download_gh_svg(parts[1], parts[0])
if value.startswith("http://") or value.startswith("https://"):
if value.startswith(("http://", "https://")):
return download_image(value)
value = cv.file_(value)
+1 -1
View File
@@ -112,7 +112,7 @@ def expand_file_to_files(config: dict):
def validate_yaml_filename(value):
value = cv.string(value)
if not (value.endswith(".yaml") or value.endswith(".yml")):
if not value.endswith((".yaml", ".yml")):
raise cv.Invalid("Only YAML (.yaml / .yml) files are supported.")
return value
+3 -3
View File
@@ -418,11 +418,11 @@ async def setup_time_core_(time_var, config):
for conf in config.get(CONF_ON_TIME, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], time_var)
seconds = conf.get(CONF_SECONDS, list(range(0, 61)))
seconds = conf.get(CONF_SECONDS, list(range(61)))
cg.add(trigger.add_seconds(seconds))
minutes = conf.get(CONF_MINUTES, list(range(0, 60)))
minutes = conf.get(CONF_MINUTES, list(range(60)))
cg.add(trigger.add_minutes(minutes))
hours = conf.get(CONF_HOURS, list(range(0, 24)))
hours = conf.get(CONF_HOURS, list(range(24)))
cg.add(trigger.add_hours(hours))
days_of_month = conf.get(CONF_DAYS_OF_MONTH, list(range(1, 32)))
cg.add(trigger.add_days_of_month(days_of_month))
+4 -2
View File
@@ -28,10 +28,12 @@ class AnsiFore(Enum):
class AnsiStyle(Enum):
# BOLD/BRIGHT and THIN/DIM are intentional ANSI synonyms; Enum treats the
# second name in each pair as an alias of the first.
BRIGHT = "\033[1m"
BOLD = "\033[1m"
BOLD = "\033[1m" # noqa: PIE796
DIM = "\033[2m"
THIN = "\033[2m"
THIN = "\033[2m" # noqa: PIE796
NORMAL = "\033[22m"
RESET_ALL = "\033[0m"
+1 -1
View File
@@ -57,7 +57,7 @@ def get_port_type(port: str) -> PortType:
"""
if port == "BOOTSEL":
return PortType.BOOTSEL
if port.startswith("/") or port.startswith("COM"):
if port.startswith(("/", "COM")):
return PortType.SERIAL
if port == "MQTT":
return PortType.MQTT