diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index cef47c8..d8cea9b 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,10 +1,10 @@ - id: autopep8-wrapper name: autopep8 wrapper description: This is deprecated, use pre-commit/mirrors-autopep8 instead. - entry: autopep8-wrapper + entry: pre-commit-hooks-removed autopep8-wrapper autopep8 https://github.com/pre-commit/mirrors-autopep8 language: python - types: [python] - args: [-i] + always_run: true + pass_filenames: false - id: check-added-large-files name: Check for added large files description: Prevent giant files from being committed @@ -140,10 +140,10 @@ - id: flake8 name: Flake8 (deprecated, use gitlab.com/pycqa/flake8) description: This hook runs flake8. (deprecated, use gitlab.com/pycqa/flake8) - entry: flake8 + entry: pre-commit-hooks-removed flake8 flake8 https://gitlab.com/pycqa/flake8 language: python - types: [python] - require_serial: true + always_run: true + pass_filenames: false - id: forbid-new-submodules name: Forbid new submodules language: python @@ -170,9 +170,10 @@ - id: pyflakes name: Pyflakes (DEPRECATED, use flake8) description: This hook runs pyflakes. (This is deprecated, use flake8). - entry: pyflakes + entry: pre-commit-hooks-removed pyflakes flake8 https://gitlab.com/pycqa/flake8 language: python - types: [python] + always_run: true + pass_filenames: false - id: requirements-txt-fixer name: Fix requirements.txt description: Sorts entries in requirements.txt diff --git a/pre_commit_hooks/autopep8_wrapper.py b/pre_commit_hooks/autopep8_wrapper.py deleted file mode 100644 index 78a1cce..0000000 --- a/pre_commit_hooks/autopep8_wrapper.py +++ /dev/null @@ -1,9 +0,0 @@ -def main() -> int: - raise SystemExit( - 'autopep8-wrapper is deprecated. Instead use autopep8 directly via ' - 'https://github.com/pre-commit/mirrors-autopep8', - ) - - -if __name__ == '__main__': - exit(main()) diff --git a/pre_commit_hooks/removed.py b/pre_commit_hooks/removed.py new file mode 100644 index 0000000..9710b2d --- /dev/null +++ b/pre_commit_hooks/removed.py @@ -0,0 +1,15 @@ +import sys +from typing import Optional +from typing import Sequence + + +def main(argv: Optional[Sequence[str]] = None) -> int: + argv = argv if argv is not None else sys.argv[1:] + hookid, new_hookid, url = argv + raise SystemExit( + f'`{hookid}` has been removed -- use `{new_hookid}` from {url}', + ) + + +if __name__ == '__main__': + exit(main()) diff --git a/setup.cfg b/setup.cfg index e6c488a..41138f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,6 @@ python_requires = >=3.6.1 [options.entry_points] console_scripts = - autopep8-wrapper = pre_commit_hooks.autopep8_wrapper:main check-added-large-files = pre_commit_hooks.check_added_large_files:main check-ast = pre_commit_hooks.check_ast:main check-builtin-literals = pre_commit_hooks.check_builtin_literals:main @@ -55,6 +54,7 @@ console_scripts = mixed-line-ending = pre_commit_hooks.mixed_line_ending:main name-tests-test = pre_commit_hooks.tests_should_end_in_test:main no-commit-to-branch = pre_commit_hooks.no_commit_to_branch:main + pre-commit-hooks-removed = pre_commit_hooks.removed:main pretty-format-json = pre_commit_hooks.pretty_format_json:main requirements-txt-fixer = pre_commit_hooks.requirements_txt_fixer:main sort-simple-yaml = pre_commit_hooks.sort_simple_yaml:main diff --git a/tests/autopep8_wrapper_test.py b/tests/autopep8_wrapper_test.py deleted file mode 100644 index f8030b5..0000000 --- a/tests/autopep8_wrapper_test.py +++ /dev/null @@ -1,10 +0,0 @@ -import pytest - -from pre_commit_hooks.autopep8_wrapper import main - - -def test_invariantly_fails(): - with pytest.raises(SystemExit) as excinfo: - main() - msg, = excinfo.value.args - assert 'https://github.com/pre-commit/mirrors-autopep8' in msg diff --git a/tests/removed_test.py b/tests/removed_test.py new file mode 100644 index 0000000..83df164 --- /dev/null +++ b/tests/removed_test.py @@ -0,0 +1,16 @@ +import pytest + +from pre_commit_hooks.removed import main + + +def test_always_fails(): + with pytest.raises(SystemExit) as excinfo: + main(( + 'autopep8-wrapper', 'autopep8', + 'https://github.com/pre-commit/mirrors-autopep8', + )) + msg, = excinfo.value.args + assert msg == ( + '`autopep8-wrapper` has been removed -- ' + 'use `autopep8` from https://github.com/pre-commit/mirrors-autopep8' + )