1
0
mirror of https://github.com/esphome/esphome.git synced 2025-06-18 06:15:46 +01:00

GH Actions Update ()

This commit is contained in:
Otto Winter
2020-07-14 14:34:44 +02:00
committed by GitHub
parent 2012c769f6
commit cf703f6ac4
15 changed files with 846 additions and 388 deletions

@ -101,10 +101,12 @@ def lint_re_check(regex, **kwargs):
if 'NOLINT' in match.group(0):
continue
lineno = content.count("\n", 0, match.start()) + 1
substr = content[:match.start()]
col = len(substr) - substr.rfind('\n')
err = func(fname, match)
if err is None:
continue
errors.append(f"{err} See line {lineno}.")
errors.append((lineno, col+1, err))
return errors
return decor(new_func)
return decorator
@ -121,8 +123,7 @@ def lint_content_find_check(find, **kwargs):
errors = []
for line, col in find_all(content, find_):
err = func(fname)
errors.append("{err} See line {line}:{col}."
"".format(err=err, line=line+1, col=col+1))
errors.append((line+1, col+1, err))
return errors
return decor(new_func)
return decorator
@ -215,9 +216,10 @@ def lint_const_ordered(fname, content):
continue
target = next(i for i, l in ordered if l == ml)
target_text = next(l for i, l in matching if target == i)
errors.append("Constant {} is not ordered, please make sure all constants are ordered. "
"See line {} (should go to line {}, {})"
"".format(highlight(ml), mi, target, target_text))
errors.append((ml, None,
"Constant {} is not ordered, please make sure all constants are ordered. "
"See line {} (should go to line {}, {})"
"".format(highlight(ml), mi, target, target_text)))
return errors
@ -354,13 +356,22 @@ errors = collections.defaultdict(list)
def add_errors(fname, errs):
if not isinstance(errs, list):
errs = [errs]
errs = [x for x in errs if x is not None]
for err in errs:
if err is None:
continue
try:
lineno, col, msg = err
except ValueError:
lineno = 1
col = 1
msg = err
if not isinstance(err, str):
raise ValueError("Error is not instance of string!")
if not errs:
return
errors[fname].extend(errs)
if not isinstance(lineno, int):
raise ValueError("Line number is not an int!")
if not isinstance(col, int):
raise ValueError("Column number is not an int!")
errors[fname].append((lineno, col, msg))
for fname in files:
@ -380,8 +391,8 @@ run_checks(LINT_POST_CHECKS, 'POST')
for f, errs in sorted(errors.items()):
print(f"\033[0;32m************* File \033[1;32m{f}\033[0m")
for err in errs:
print(err)
for lineno, col, msg in errs:
print(f"ERROR {f}:{lineno}:{col} - {msg}")
print()
sys.exit(len(errors))