Adding a bunch of flake8 extensions and working through the errors
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from termcolor import cprint
|
||||
|
||||
print_re = re.compile(r'print\(.*\)')
|
||||
todo_re = re.compile(r'#\s*TODO:?\s*')
|
||||
accounted_for_todo = re.compile(r'#\s*TODO:?\s*\((#\d+)\)')
|
||||
|
||||
|
||||
def check_file(path):
|
||||
print(f'Checking {path.absolute()}...')
|
||||
def check_file(path: Path) -> bool:
|
||||
print(f'Checking {path.absolute()}...') # noqa: T001
|
||||
file = path.open()
|
||||
valid = True
|
||||
|
||||
for i, line in enumerate(file, start=1):
|
||||
if print_re.search(line) and '# allowprint' not in line:
|
||||
cprint(f'{i}: {line}', 'red', end='', attrs=['bold'])
|
||||
valid = False
|
||||
|
||||
if todo_re.search(line) and not accounted_for_todo.search(line):
|
||||
cprint(f'{i}: {line}', 'red', end='', attrs=['bold'])
|
||||
valid = False
|
||||
@@ -33,6 +27,6 @@ def check_file(path):
|
||||
valid = True
|
||||
for path in Path('sublime').glob('**/*.py'):
|
||||
valid &= check_file(path)
|
||||
print()
|
||||
print() # noqa: T001
|
||||
|
||||
sys.exit(0 if valid else 1)
|
||||
|
Reference in New Issue
Block a user