mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 04:54:16 +00:00
demo
This commit is contained in:
parent
78818b90cd
commit
8b2066fb27
3 changed files with 32 additions and 0 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
- id: pep8-check
|
||||||
|
name: pep8 check
|
||||||
|
description: "demo"
|
||||||
|
entry: pep8-check
|
||||||
|
language: python
|
||||||
|
files: \.py$
|
||||||
|
args: [-i]
|
||||||
- id: autopep8-wrapper
|
- id: autopep8-wrapper
|
||||||
name: autopep8 wrapper
|
name: autopep8 wrapper
|
||||||
description: "Runs autopep8 over python source. If you configure additional arguments you'll want to at least include -i."
|
description: "Runs autopep8 over python source. If you configure additional arguments you'll want to at least include -i."
|
||||||
|
|
|
||||||
24
pre_commit_hooks/pep8_check.py
Normal file
24
pre_commit_hooks/pep8_check.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import io
|
||||||
|
import sys
|
||||||
|
import xml.sax
|
||||||
|
from pre_commit_hooks.util import cmd_output
|
||||||
|
|
||||||
|
|
||||||
|
def check_pep8(argv=None):
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('filenames', nargs='*', help='XML filenames to check.')
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
print (args)
|
||||||
|
|
||||||
|
retval = 0
|
||||||
|
lines = cmd_output("git diff --cached -- '*.py' | "
|
||||||
|
"`which pep8` --max-line-length=119 --show-source --diff --ignore=E402,E731").splitlines()
|
||||||
|
if len(lines) > 0:
|
||||||
|
print (lines)
|
||||||
|
retval = 1
|
||||||
|
return retval
|
||||||
1
setup.py
1
setup.py
|
|
@ -33,6 +33,7 @@ setup(
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
'pep8-check = pre_commit_hooks.pep8_check:main',
|
||||||
'autopep8-wrapper = pre_commit_hooks.autopep8_wrapper:main',
|
'autopep8-wrapper = pre_commit_hooks.autopep8_wrapper:main',
|
||||||
'check-added-large-files = pre_commit_hooks.check_added_large_files:main',
|
'check-added-large-files = pre_commit_hooks.check_added_large_files:main',
|
||||||
'check-ast = pre_commit_hooks.check_ast:check_ast',
|
'check-ast = pre_commit_hooks.check_ast:check_ast',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue