1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Cache AST module parsing in hassfest (#132244)

This commit is contained in:
epenet
2024-12-06 20:55:34 +01:00
committed by GitHub
parent e54d929573
commit 9771998415
10 changed files with 32 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ from pathlib import Path
from homeassistant.const import Platform
from homeassistant.requirements import DISCOVERY_INTEGRATIONS
from . import ast_parse_module
from .model import Config, Integration
@@ -33,7 +34,7 @@ class ImportCollector(ast.NodeVisitor):
self._cur_fil_dir = fil.relative_to(self.integration.path)
self.referenced[self._cur_fil_dir] = set()
try:
self.visit(ast.parse(fil.read_text()))
self.visit(ast_parse_module(fil))
except SyntaxError as e:
e.add_note(f"File: {fil}")
raise