mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 10:16:52 +00:00
Respond to review feedback
This commit is contained in:
parent
4af7451154
commit
b941d0e6df
4 changed files with 9 additions and 14 deletions
|
|
@ -110,7 +110,7 @@
|
|||
description: Sort the lines in specified files (defaults to alphabetical). You must provide list of target files as input in your .pre-commit-config.yaml file.
|
||||
entry: file-contents-sorter
|
||||
language: python
|
||||
files: ''
|
||||
files: '^$'
|
||||
- id: fix-encoding-pragma
|
||||
name: Fix python encoding pragma
|
||||
language: python
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ FAIL = 1
|
|||
|
||||
|
||||
def sort_file_contents(f):
|
||||
before = [line for line in f]
|
||||
before = list(f)
|
||||
after = sorted(before)
|
||||
|
||||
before_string = b''.join(before)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
coverage
|
||||
flake8
|
||||
ipdb
|
||||
mock
|
||||
pre-commit
|
||||
pytest
|
||||
|
|
|
|||
|
|
@ -6,21 +6,17 @@ from pre_commit_hooks.file_contents_sorter import parse_commandline_input
|
|||
from pre_commit_hooks.file_contents_sorter import PASS
|
||||
|
||||
|
||||
def _n(*strs):
|
||||
return b'\n'.join(strs) + b'\n'
|
||||
|
||||
|
||||
# Input, expected return value, expected output
|
||||
TESTS = (
|
||||
(b'', PASS, b''),
|
||||
(_n(b'lonesome'), PASS, _n(b'lonesome')),
|
||||
(b'lonesome\n', PASS, b'lonesome\n'),
|
||||
(b'missing_newline', PASS, b'missing_newline'),
|
||||
(_n(b'alpha', b'beta'), PASS, _n(b'alpha', b'beta')),
|
||||
(_n(b'beta', b'alpha'), FAIL, _n(b'alpha', b'beta')),
|
||||
(_n(b'C', b'c'), PASS, _n(b'C', b'c')),
|
||||
(_n(b'c', b'C'), FAIL, _n(b'C', b'c')),
|
||||
(_n(b'mag ical ', b' tre vor'), FAIL, _n(b' tre vor', b'mag ical ')),
|
||||
(_n(b'@', b'-', b'_', b'#'), FAIL, _n(b'#', b'-', b'@', b'_')),
|
||||
(b'alpha\nbeta\n', PASS, b'alpha\nbeta\n'),
|
||||
(b'beta\nalpha\n', FAIL, b'alpha\nbeta\n'),
|
||||
(b'C\nc\n', PASS, b'C\nc\n'),
|
||||
(b'c\nC\n', FAIL, b'C\nc\n'),
|
||||
(b'mag ical \n tre vor\n', FAIL, b' tre vor\nmag ical \n'),
|
||||
(b'@\n-\n_\n#\n', FAIL, b'#\n-\n@\n_\n'),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue