diff --git a/scripts/misc_checks.py b/scripts/misc_checks.py index 36bc28079..c6033cf3b 100644 --- a/scripts/misc_checks.py +++ b/scripts/misc_checks.py @@ -35,9 +35,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir)) from scripts import utils -def _py_files(target): +def _py_files(): """Iterate over all python files and yield filenames.""" - for (dirpath, _dirnames, filenames) in os.walk(target): + for (dirpath, _dirnames, filenames) in os.walk('.'): + parts = dirpath.split(os.sep) + if len(parts) >= 2 and parts[1].startswith('.'): + # ignore hidden dirs + continue for name in (e for e in filenames if e.endswith('.py')): yield os.path.join(dirpath, name) @@ -64,7 +68,7 @@ def check_git(): return status -def check_spelling(target): +def check_spelling(): """Check commonly misspelled words.""" # Words which I often misspell words = {'behaviour', 'quitted', 'likelyhood', 'sucessfully', @@ -81,9 +85,9 @@ def check_spelling(target): seen = collections.defaultdict(list) try: ok = True - for fn in _py_files(target): + for fn in _py_files(): with tokenize.open(fn) as f: - if fn == os.path.join('scripts', 'misc_checks.py'): + if fn == os.path.join('.', 'scripts', 'misc_checks.py'): continue for line in f: for w in words: @@ -98,11 +102,11 @@ def check_spelling(target): return None -def check_vcs_conflict(target): +def check_vcs_conflict(): """Check VCS conflict markers.""" try: ok = True - for fn in _py_files(target): + for fn in _py_files(): with tokenize.open(fn) as f: for line in f: if any(line.startswith(c * 7) for c in '<>=|'): @@ -120,25 +124,14 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('checker', choices=('git', 'vcs', 'spelling'), help="Which checker to run.") - parser.add_argument('target', help="What to check", nargs='*') args = parser.parse_args() if args.checker == 'git': ok = check_git() - return 0 if ok else 1 elif args.checker == 'vcs': - is_ok = True - for target in args.target: - ok = check_vcs_conflict(target) - if not ok: - is_ok = False - return 0 if is_ok else 1 + ok = check_vcs_conflict() elif args.checker == 'spelling': - is_ok = True - for target in args.target: - ok = check_spelling(target) - if not ok: - is_ok = False - return 0 if is_ok else 1 + ok = check_spelling() + return 0 if ok else 1 if __name__ == '__main__': diff --git a/tox.ini b/tox.ini index b24842ff4..7717dd8ec 100644 --- a/tox.ini +++ b/tox.ini @@ -46,8 +46,8 @@ commands = [testenv:misc] commands = {envpython} scripts/misc_checks.py git - {envpython} scripts/misc_checks.py vcs qutebrowser scripts tests - {envpython} scripts/misc_checks.py spelling qutebrowser scripts tests + {envpython} scripts/misc_checks.py vcs + {envpython} scripts/misc_checks.py spelling [testenv:pylint] skip_install = true