Skip to content

Commit

Permalink
Bug #3 fixed for __init__.py files only
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdah committed Dec 4, 2012
1 parent 6f3fcd1 commit a4b5622
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ This commit hook is written in Python and has the following requirements:
Release notes
-------------

### 0.6 (2012-12-04)

- Fixed bug [#3 Empty .py files fails according to pylint](https://github.com/sebdah/git-pylint-commit-hook/issues/3)

### 0.5 (2012-12-01)

- Fixed bug [#2 Hook missed some Python files when committing a mixture of file types](https://github.com/sebdah/git-pylint-commit-hook/issues/2)
Expand Down
14 changes: 13 additions & 1 deletion pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AUTHOR:
Sebastian Dahlgren <sebastian.dahlgren@gmail.com>
VERSION:
0.5
0.6
LICENSE:
Apache License 2.0
Expand All @@ -30,6 +30,7 @@ LIMIT = 8.0
#
#######################################

import os
import re
import sys
import subprocess
Expand Down Expand Up @@ -67,6 +68,7 @@ def checker():
python_files.append((filename, None))
continue

# Check the first line for a python shebang
try:
with open(filename, 'r') as file_handle:
first_line = file_handle.readline()
Expand All @@ -83,6 +85,16 @@ def checker():
i = 1
regexp = re.compile(r'^Your\ code\ has\ been\ rated\ at\ ([0-9\.]+)/10')
for python_file, score in python_files:
# Allow __init__.py files to be completely empty
if os.path.basename(python_file) == '__init__.py':
if os.stat('__init__.py').st_size == 0:
print 'Skipping pylint on %s (empty __init__.py)..\tSKIPPED' % (
python_file)

# Bump parsed files
i += 1
continue

# Set the initial score
score = 0.00

Expand Down

0 comments on commit a4b5622

Please sign in to comment.