1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 03:42:20 +01:00

Add config validator location (#1490)

* show validation source location for id

* show validation source location for lambda

* refactor lambda #line position

* account content offset on made lambdas

* lint

* remove redundant check
This commit is contained in:
Guillermo Ruffino
2021-02-06 12:09:15 -03:00
committed by GitHub
parent de3377132d
commit 28e39f7f76
5 changed files with 30 additions and 31 deletions

View File

@@ -2,6 +2,7 @@ import abc
import inspect
import math
import re
from esphome.yaml_util import ESPHomeDataBase
# pylint: disable=unused-import, wrong-import-order
from typing import Any, Generator, List, Optional, Tuple, Type, Union, Sequence
@@ -560,7 +561,13 @@ def process_lambda(
else:
parts[i * 3 + 1] = var
parts[i * 3 + 2] = ''
yield LambdaExpression(parts, parameters, capture, return_type, value.source_location)
if isinstance(value, ESPHomeDataBase) and value.esp_range is not None:
location = value.esp_range.start_mark
location.line += value.content_offset
else:
location = None
yield LambdaExpression(parts, parameters, capture, return_type, location)
def is_template(value):