From e1d3549ce3c6f4293a33690c0ce52c8935b8c828 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 10 Feb 2025 12:53:44 +0100 Subject: [PATCH] Improve blueprint importer typing (#138194) --- homeassistant/components/blueprint/importer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/blueprint/importer.py b/homeassistant/components/blueprint/importer.py index 8582761bafb..83afa511b68 100644 --- a/homeassistant/components/blueprint/importer.py +++ b/homeassistant/components/blueprint/importer.py @@ -6,6 +6,7 @@ from contextlib import suppress from dataclasses import dataclass import html import re +from typing import TYPE_CHECKING import voluptuous as vol import yarl @@ -195,8 +196,8 @@ async def fetch_blueprint_from_github_gist_url( ) gist = await resp.json() - blueprint = None - filename = None + blueprint: Blueprint | None = None + filename: str | None = None content: str for filename, info in gist["files"].items(): @@ -218,6 +219,8 @@ async def fetch_blueprint_from_github_gist_url( "No valid blueprint found in the gist. The blueprint file needs to end with" " '.yaml'" ) + if TYPE_CHECKING: + assert isinstance(filename, str) return ImportedBlueprint( f"{gist['owner']['login']}/{filename[:-5]}", content, blueprint