Commit 651a04d5 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add Pylint pre-commit hook

parent 89e534bb
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -91,5 +91,37 @@ include =
  ; B950 is a replacement for E501
  B0 B903 B950

[pylint.MASTER]
persistent=yes
ignore =
  __pycache__
  .*

[pylint.BASIC]
const-rgx = (([A-Z_][A-Z0-9_]*)|(_[A-Za-z0-9_]+))$
good-names = db, i, a, b, ab, t, fd

[pylint.REPORTS]
reports = no

[pylint.FORMAT]
indent-string = '\t'

[pylint.DESIGN]
max-attributes = 10

[pylint.MESSAGES CONTROL]
disable =
  bad-continuation,
  ; Would be nice to not disable but it is bugged; it trys to interpret tabs as
  ; spaces.

  trailing-whitespace,
  ; Would be nice to have enabled for *code* but not for comments or
  ; multi-line strings.

  wrong-import-order,
  ; Rely on isort, otherwise pylint and isort occasionally clash.


; vim:ft=cfg:sw=2:sts=2:expandtab
+6 −0
Original line number Diff line number Diff line
@@ -55,3 +55,9 @@ repos:
    - flake8-return
    - flake8-sfs
    - flake8-tabs

- repo: .
  rev: v0.3
  hooks:
  - id: pylint
    args: ["--fail-under=9.0", "--rcfile=.lint"]
+7 −4
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ from pylint import lint
__version__ = '0.3'


@click.command()
@click.command(context_settings=dict(
	ignore_unknown_options=True,
))
@click.option(
	'--extras', '-e',
	multiple=True,
@@ -37,8 +39,8 @@ __version__ = '0.3'
	default=isfile('setup.py'),
	help="Use the editable install (develop) feature provided by setuptools",
)
@click.argument('files', nargs=-1)
def main(extras, fail_under, editable, files):
@click.argument('pylint-options', nargs=-1, type=click.UNPROCESSED)
def main(extras, fail_under, editable, pylint_options):
	"""Invoke Pylint on the given files after ensuring dependencies are up to date"""
	join = ','.join
	cmd = ['pip', 'install', '--upgrade']
@@ -59,7 +61,7 @@ def main(extras, fail_under, editable, files):
		sys.stderr.write(exc.stderr)
		sys.exit(3)

	run = lint.Run(files, do_exit=False)
	run = lint.Run(list(pylint_options), do_exit=False)
	score = run.linter.stats['global_note']

	if score < fail_under:
@@ -67,4 +69,5 @@ def main(extras, fail_under, editable, files):


if __name__ == '__main__':
	# pylint: disable=no-value-for-parameter
	main()