Fix linter errors; use custom check for print statements because flake8-print is not working anymore
This commit is contained in:
@@ -6,8 +6,17 @@ from pathlib import Path
|
||||
|
||||
from termcolor import cprint
|
||||
|
||||
todo_re = re.compile(r"#\s*TODO:?\s*")
|
||||
accounted_for_todo = re.compile(r"#\s*TODO:?\s*\((#\d+)\)")
|
||||
todo_re = re.compile(r"\s*#\s*TODO:?\s*")
|
||||
accounted_for_todo = re.compile(r"\s*#\s*TODO:?\s*\((#\d+)\)")
|
||||
print_re = re.compile(r"\s+print\(.*\)")
|
||||
|
||||
|
||||
def noqa_re(error_id: str = ""):
|
||||
return re.compile(rf"#\s*noqa(:\s*{error_id})?\s*\n$")
|
||||
|
||||
|
||||
def eprint(*strings):
|
||||
cprint(" ".join(strings), "red", end="", attrs=["bold"])
|
||||
|
||||
|
||||
def check_file(path: Path) -> bool:
|
||||
@@ -16,8 +25,12 @@ def check_file(path: Path) -> bool:
|
||||
valid = True
|
||||
|
||||
for i, line in enumerate(file, start=1):
|
||||
if todo_re.search(line) and not accounted_for_todo.search(line):
|
||||
cprint(f"{i}: {line}", "red", end="", attrs=["bold"])
|
||||
if todo_re.match(line) and not accounted_for_todo.match(line):
|
||||
eprint(f"{i}: {line}")
|
||||
valid = False
|
||||
|
||||
if print_re.search(line) and not noqa_re("T001").search(line):
|
||||
eprint(f"{i}: {line}")
|
||||
valid = False
|
||||
|
||||
file.close()
|
||||
|
Reference in New Issue
Block a user