From c07a5a8da46fd86d05ff250e5aaa6eb947c2d48c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 21 Aug 2026 14:32:27 -0500 Subject: [PATCH] Match the encoder's lower bound to the PlatformIO era guard, drop the unused logger <= 2.6.2 instead of < 2.6.3: a 2.6.2 pre-release sorts above 2.6.2 and belongs to the package-major-3 encoding, so the helper now describes the same set as _format_framework_arduino_version and a 2.6.2-b1 pin formats as it does on dev. The module never logged, so its _LOGGER and logging import go. --- esphome/arduino8266/framework.py | 16 +++++++--------- tests/unit_tests/test_arduino8266_framework.py | 7 +++++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/esphome/arduino8266/framework.py b/esphome/arduino8266/framework.py index b27744cb20..b4f20d5b04 100644 --- a/esphome/arduino8266/framework.py +++ b/esphome/arduino8266/framework.py @@ -19,7 +19,6 @@ toolchain has always used, so the bits are identical); the from __future__ import annotations import functools -import logging import os from pathlib import Path from typing import NamedTuple @@ -31,8 +30,6 @@ from esphome.core import EsphomeError, Version from esphome.framework_helpers import str_to_lst_of_str from esphome.platformio.registry import install_package -_LOGGER = logging.getLogger(__name__) - FRAMEWORK_PACKAGE = "framework-arduinoespressif8266" TOOLCHAIN_PACKAGE = "toolchain-xtensa" # gcc 10.3, the toolchain Arduino core 3.x builds with. The compile flags in @@ -75,13 +72,14 @@ def framework_package_version(ver: Version) -> str: f"Arduino core {ver} is not supported yet; " "the newest known core series is 3.x" ) - if ver < Version(2, 6, 3): - # Older cores use the 1.x/2.x package-major encodings, which the - # PlatformIO path handles before delegating here; never encode them - # wrongly for a caller that skipped that guard + if ver <= Version(2, 6, 2): + # Same boundary as _format_framework_arduino_version's era guard (a + # 2.6.2 pre-release sorts above 2.6.2 and belongs to this encoding). + # Older cores use the 1.x/2.x package-major encodings; never encode + # them wrongly for a caller that skipped that guard raise EsphomeError( - f"Arduino core {ver} predates the package encoding this helper " - "implements (2.6.3 and newer)" + f"Arduino core {ver} uses an older package encoding than this " + "helper implements (newer than 2.6.2)" ) return f"3.{ver.major}{ver.minor:02d}{ver.patch:02d}.0" diff --git a/tests/unit_tests/test_arduino8266_framework.py b/tests/unit_tests/test_arduino8266_framework.py index cdd1ae0417..74a20c85fb 100644 --- a/tests/unit_tests/test_arduino8266_framework.py +++ b/tests/unit_tests/test_arduino8266_framework.py @@ -27,9 +27,12 @@ def test_framework_package_version() -> None: # A future major bump needs its own encoding, not a doomed registry lookup with pytest.raises(EsphomeError, match="not supported yet"): framework.framework_package_version(cv.Version(4, 0, 0)) - # The pre-2.6.3 eras use other encodings; the helper is total, not wrong - with pytest.raises(EsphomeError, match="predates the package encoding"): + # Cores up to 2.6.2 use other encodings; the helper is total, not wrong, + # and its boundary matches the PlatformIO era guard: a 2.6.2 pre-release + # sorts above 2.6.2 and keeps the package-major-3 encoding + with pytest.raises(EsphomeError, match="older package encoding"): framework.framework_package_version(cv.Version(2, 6, 2)) + assert framework.framework_package_version(cv.Version(2, 6, 2, "b1")) == "3.20602.0" assert framework.framework_package_version(cv.Version(2, 6, 3)) == "3.20603.0"