Merge pull request #936 from szepeviktor/patch-1
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8e6f00..99d4b38 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml
@@ -19,24 +19,24 @@ - id: reorder-python-imports args: [--py38-plus, --add-import, 'from __future__ import annotations'] - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.0 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.10.1 hooks: - id: pyupgrade args: [--py38-plus] -- repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v2.0.2 +- repo: https://github.com/hhatto/autopep8 + rev: v2.0.4 hooks: - id: autopep8 - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.5.1 hooks: - id: mypy additional_dependencies: [types-all]
diff --git a/pre_commit_hooks/debug_statement_hook.py b/pre_commit_hooks/debug_statement_hook.py index 9ada657..cf544c7 100644 --- a/pre_commit_hooks/debug_statement_hook.py +++ b/pre_commit_hooks/debug_statement_hook.py
@@ -8,6 +8,7 @@ DEBUG_STATEMENTS = { + 'bpdb', 'ipdb', 'pdb', 'pdbr',
diff --git a/pre_commit_hooks/file_contents_sorter.py b/pre_commit_hooks/file_contents_sorter.py index c5691f0..02bdbcc 100644 --- a/pre_commit_hooks/file_contents_sorter.py +++ b/pre_commit_hooks/file_contents_sorter.py
@@ -37,7 +37,10 @@ after = sorted(lines, key=key) before_string = b''.join(before) - after_string = b'\n'.join(after) + b'\n' + after_string = b'\n'.join(after) + + if after_string: + after_string += b'\n' if before_string == after_string: return PASS
diff --git a/tests/file_contents_sorter_test.py b/tests/file_contents_sorter_test.py index 5e79e40..49b3b79 100644 --- a/tests/file_contents_sorter_test.py +++ b/tests/file_contents_sorter_test.py
@@ -10,7 +10,9 @@ @pytest.mark.parametrize( ('input_s', 'argv', 'expected_retval', 'output'), ( - (b'', [], FAIL, b'\n'), + (b'', [], PASS, b''), + (b'\n', [], FAIL, b''), + (b'\n\n', [], FAIL, b''), (b'lonesome\n', [], PASS, b'lonesome\n'), (b'missing_newline', [], FAIL, b'missing_newline\n'), (b'newline\nmissing', [], FAIL, b'missing\nnewline\n'),