Skip to content

Commit 61788ec

Browse files
committed
Supporting custom command line params to pylint #6
1 parent 5a015ee commit 61788ec

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ Don't forget to make it executable.
1818
Usage
1919
------
2020

21-
The commit hook will automatically be called when you are running `git commit`. If you want to skip the tests for a certain commit, use the `-n` flag, `git commit -n`.
21+
The commit hook will automatically be called when you are running `git commit`. If you want to skip the tests for a certain commit, use the `-n` flag, `git commit -n`.
22+
23+
### Setting score limit
24+
25+
Open the `pre-commit` script and update the `LIMIT` value according to your needs. E.g.
26+
27+
LIMIT = 8.0
28+
29+
### Custom `pylint` command line options
30+
31+
The hook supports custom command line options to be specified. Those can be added to the `PYLINT_PARAMS` inside the `pre-commit` script. E.g.
32+
33+
PYLINT_PARAMS = '--rcfile=/path/to/project/pylint.rc'
2234

2335

2436
Requirements

pre-commit

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ LICENSE:
2424
# The lowest allowed score (should be a float between 0.00 and 10.00)
2525
LIMIT = 8.0
2626

27+
# Custom pylint command line parameters. See pylint --help for more info
28+
# E.g.
29+
# PYLINT_PARAMS = '--rcfile=/path/to/project/pylint.rc'
30+
PYLINT_PARAMS = ''
31+
2732
#######################################
2833
#
2934
# CODE BELOW
@@ -103,8 +108,13 @@ def checker():
103108
python_file, i, len(python_files)))
104109
sys.stdout.flush()
105110
try:
111+
if PYLINT_PARAMS:
112+
# Use without extra config file
113+
command = 'pylint %s' % python_file
114+
else:
115+
command = 'pylint %s %s' % (PYLINT_PARAMS, python_file)
106116
proc = subprocess.Popen(
107-
('pylint %s' % python_file).split(),
117+
command.split(),
108118
stdout=subprocess.PIPE,
109119
stderr=subprocess.PIPE)
110120
out, _ = proc.communicate()

0 commit comments

Comments
 (0)