Skip to content

HA 2026.5 support#828

Merged
craigbarratt merged 9 commits intocustom-components:masterfrom
dmamelin:ha-2026-5
May 2, 2026
Merged

HA 2026.5 support#828
craigbarratt merged 9 commits intocustom-components:masterfrom
dmamelin:ha-2026-5

Conversation

@dmamelin
Copy link
Copy Markdown
Contributor

@dmamelin dmamelin commented May 1, 2026

Fixing #827 required updating pytest-homeassistant-custom-component, which in turn requires Python 3.14.
But after moving to the new Python version, the tests broke: HA could no longer load the pyscript integration because os.path.isfile was being patched globally in the tests.

I don't know why this worked before - homeassistant/loader.py hasn't changed in a long time. Most likely this is due to changes in CPython: python/cpython#118243

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 1, 2026

A small dependency-version hell - everything works locally, but I need a bit more time.

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

I pinned the minimal version to 2026.5.0 expecting the usual May 1 release, but it's now scheduled for May 6.

@rccoleman
Copy link
Copy Markdown
Contributor

I pinned the minimal version to 2026.5.0 expecting the usual May 1 release, but it's now scheduled for May 6.

HA releases are always on the first Wed of the month. Betas start on the last Wed of the month.

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

My mistake. However, I suggest leaving this unchanged and keeping Home Assistant 2026.5.0 as the requirement for Pyscript 2.0.

For regular users, the HA and Pyscript updates will be released at the same time.

@craigbarratt
Copy link
Copy Markdown
Member

craigbarratt commented May 2, 2026

@dmamelin thanks for the fixes. Just wondering what the most prudent release strategy is

  1. do a stepping-stone release with these fixes for 2026.5.0 without Decorator Manager #818
  2. release 2.0.0 now with all PRs and fixes for 2026.5.0

I think the 2nd is the best option, although we will be front-loading issues on top of the 2026.5.0 changes since there won't be any fallback with 2026.5.0 support, nor a beta-test period with #818.

Also, how important is it for 2.0.0 to be backward compatible with HA < 2026.5.0? I don't this PR will be backward compatible.

Thoughts?

@craigbarratt craigbarratt merged commit 6ad0e19 into custom-components:master May 2, 2026
6 checks passed
@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

@craigbarratt i prefer the second option. There's no point in excluding #818, because the legacy_decorators option exists.
BTW, there may still be bugs in the recent changes, but I'll be fixing them quickly.

@craigbarratt
Copy link
Copy Markdown
Member

craigbarratt commented May 2, 2026

Ok, great, I agree - forward progress without orphan releases. I'm going to update the imports in this PR to hopefully make it backward compatible (with try / except on the imports). See below.

Also, there were changes from "except (ValueError, TypeError)" to "except ValueError, TypeError". I believe the former is correct, so I'll change them back.

try:
    from homeassistant.helpers.template.extensions.math import _SENTINEL as MATH_SENTINEL, MathExtension
    from homeassistant.helpers.template.extensions.type_cast import (
        TypeCastExtension,
        _SENTINEL as TYPECAST_SENTINEL,
    )
    from homeassistant.helpers.template.helpers import (
        _SENTINEL,
        forgiving_boolean,
        raise_no_default,
    )
except ImportError:
    from homeassistant.helpers.template import (  # type: ignore[no-redef]
        _SENTINEL,
        forgiving_boolean,
        forgiving_float as _forgiving_float,
        forgiving_int as _forgiving_int,
        forgiving_round as _forgiving_round,
        raise_no_default,
    )

    TYPECAST_SENTINEL = _SENTINEL
    MATH_SENTINEL = _SENTINEL

    class TypeCastExtension:  # type: ignore[no-redef]
        """Shim for older HA versions that export forgiving_* as module-level functions."""

        @staticmethod
        def forgiving_float(value, default=_SENTINEL):
            return _forgiving_float(value, default=default)

        @staticmethod
        def forgiving_int(value, default=_SENTINEL, base=10):
            return _forgiving_int(value, default=default, base=base)

    class MathExtension:  # type: ignore[no-redef]
        """Shim for older HA versions that export forgiving_round as a module-level function."""

        @staticmethod
        def forgiving_round(value, precision=0, method="common", default=_SENTINEL):
            return _forgiving_round(value, precision=precision, method=method, default=default)

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

Also, there were changes from "except (ValueError, TypeError)" to "except ValueError, TypeError". I believe the former is correct, so I'll change them back.

@craigbarratt this is required by the new ruff format. Reverting to the previous style and ignoring the new PEP would mean sticking with an older ruff version.

The idea of using try / except on the imports is excellent.

@craigbarratt
Copy link
Copy Markdown
Member

@dmamelin good point about PEP 758. However, it's a syntax error in python <= 3.13. I'd rather keep backward compatibility for a few months, and we'll need to pin an older ruff version.

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

I'll try to be more mindful of backward compatibility :)

My reasoning was simple: if a user updates integrations through HACS, Home Assistant itself is usually up to date as well. And Python >= 3.14.2 is required for Home Assistant starting from 2026.3.0

craigbarratt added a commit that referenced this pull request May 2, 2026
also down-revd ruff target-version to py313
@craigbarratt
Copy link
Copy Markdown
Member

@dmamelin Ok, this should be backward compatible. Anything else to do or check before releasing 2.0.0?

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

@craigbarratt i don't know the full release process, but from the code side everything is ready.

@craigbarratt
Copy link
Copy Markdown
Member

2.0.0 released!

@dmamelin
Copy link
Copy Markdown
Contributor Author

dmamelin commented May 2, 2026

@craigbarratt thanks! Hopefully the release is boring in the best possible way :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants