diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-11-26 00:26:23 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-11-26 00:26:23 +0100 |
commit | 907a19e123bfe2a8bfdf1b69c16d73c61f27e7a3 (patch) | |
tree | 93711b4dae3d0f5fb2853429aafb85d7dba72ca4 | |
parent | fb9bd7f445081b024c7a1c7dfab8949d2e6496fb (diff) | |
download | psutil-907a19e123bfe2a8bfdf1b69c16d73c61f27e7a3.tar.gz |
GIT pre-commit script: exit if line ends with space
-rwxr-xr-x | .git-pre-commit | 20 | ||||
-rw-r--r-- | docs/conf.py | 1 | ||||
-rwxr-xr-x | scripts/nettop.py | 1 |
3 files changed, 12 insertions, 10 deletions
diff --git a/.git-pre-commit b/.git-pre-commit index e15884d1..071957d1 100755 --- a/.git-pre-commit +++ b/.git-pre-commit @@ -54,23 +54,23 @@ def main(): py_files = [x for x in out.split(b'\n') if x.endswith(b'.py') and os.path.exists(x)] + lineno = 0 for path in py_files: with open(path) as f: - data = f.read() - - # pdb - if "pdb.set_trace" in data: - for lineno, line in enumerate(data.split('\n'), 1): + for line in f: + lineno += 1 + # space at end of line + if line.endswith(' '): + print("%s:%s %r" % (path, lineno, line)) + return exit( + "commit aborted: space at end of line") line = line.rstrip() + # pdb if "pdb.set_trace" in line: print("%s:%s %s" % (path, lineno, line)) return exit( "commit aborted: you forgot a pdb in your python code") - - # bare except clause - if "except:" in data: - for lineno, line in enumerate(data.split('\n'), 1): - line = line.rstrip() + # bare except clause if "except:" in line and not line.endswith("# NOQA"): print("%s:%s %s" % (path, lineno, line)) return exit("commit aborted: bare except clause") diff --git a/docs/conf.py b/docs/conf.py index 9fa163b6..2267b5d1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,6 +35,7 @@ def get_version(): else: raise ValueError("couldn't find version string") + VERSION = get_version() # If your documentation needs a minimal Sphinx version, state it here. diff --git a/scripts/nettop.py b/scripts/nettop.py index 97f80aad..e13903c1 100755 --- a/scripts/nettop.py +++ b/scripts/nettop.py @@ -49,6 +49,7 @@ def tear_down(): curses.echo() curses.endwin() + win = curses.initscr() atexit.register(tear_down) curses.endwin() |