mirror of
https://github.com/home-assistant/core
synced 2024-10-04 19:02:19 +00:00
Augment SyntaxError raised during dependency collection with offending filename (#109204)
* Capture parsing exception when collecting dependencies and augment with offending filename. Whereas before any syntax error in some component-file would result in an opaque SyntaxError without pointing out the file, now the result will show as: ``` File "/usr/local/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", line 873, in next raise value SyntaxError: Can't parse file homeassistant/components/your/file.py ``` * tweak * D'oh, had pre-commit hook still off. --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
90efe5ac90
commit
5e250d8a76
|
@ -32,7 +32,11 @@ class ImportCollector(ast.NodeVisitor):
|
|||
|
||||
self._cur_fil_dir = fil.relative_to(self.integration.path)
|
||||
self.referenced[self._cur_fil_dir] = set()
|
||||
self.visit(ast.parse(fil.read_text()))
|
||||
try:
|
||||
self.visit(ast.parse(fil.read_text()))
|
||||
except SyntaxError as e:
|
||||
e.add_note(f"File: {fil}")
|
||||
raise
|
||||
self._cur_fil_dir = None
|
||||
|
||||
def _add_reference(self, reference_domain: str) -> None:
|
||||
|
|
Loading…
Reference in a new issue