Improve blueprint importer typing (#138194)

This commit is contained in:
Marc Mueller 2025-02-10 12:53:44 +01:00 committed by GitHub
parent b89f9a5961
commit e1d3549ce3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -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