mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Improve blueprint importer typing (#138194)
This commit is contained in:
parent
b89f9a5961
commit
e1d3549ce3
@ -6,6 +6,7 @@ from contextlib import suppress
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import html
|
import html
|
||||||
import re
|
import re
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
import yarl
|
import yarl
|
||||||
@ -195,8 +196,8 @@ async def fetch_blueprint_from_github_gist_url(
|
|||||||
)
|
)
|
||||||
gist = await resp.json()
|
gist = await resp.json()
|
||||||
|
|
||||||
blueprint = None
|
blueprint: Blueprint | None = None
|
||||||
filename = None
|
filename: str | None = None
|
||||||
content: str
|
content: str
|
||||||
|
|
||||||
for filename, info in gist["files"].items():
|
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"
|
"No valid blueprint found in the gist. The blueprint file needs to end with"
|
||||||
" '.yaml'"
|
" '.yaml'"
|
||||||
)
|
)
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
assert isinstance(filename, str)
|
||||||
|
|
||||||
return ImportedBlueprint(
|
return ImportedBlueprint(
|
||||||
f"{gist['owner']['login']}/{filename[:-5]}", content, blueprint
|
f"{gist['owner']['login']}/{filename[:-5]}", content, blueprint
|
||||||
|
Loading…
x
Reference in New Issue
Block a user