Skip to content

Commit 08e2918

Browse files
authored
Merge pull request #321 from pre-commit/suggest_mirrors_autopep8
Remove autopep8-wrapper in favor of autopep8
2 parents c9a608a + 526904b commit 08e2918

File tree

5 files changed

+20
-49
lines changed

5 files changed

+20
-49
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ repos:
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
7-
- id: autopep8-wrapper
87
- id: check-docstring-first
98
- id: check-json
109
- id: check-added-large-files
@@ -13,6 +12,10 @@ repos:
1312
- id: name-tests-test
1413
- id: requirements-txt-fixer
1514
- id: flake8
15+
- repo: https://github.com/pre-commit/mirrors-autopep8
16+
rev: v1.4
17+
hooks:
18+
- id: autopep8
1619
- repo: https://github.com/pre-commit/pre-commit
1720
rev: v1.7.0
1821
hooks:

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ Add this to your `.pre-commit-config.yaml`
2323

2424
### Hooks available
2525

26-
- `autopep8-wrapper` - Runs autopep8 over python source.
27-
- Ignore PEP 8 violation types with `args: ['-i', '--ignore=E000,...']` or
28-
through configuration of the `[pycodestyle]` section in
29-
setup.cfg / tox.ini.
3026
- `check-added-large-files` - Prevent giant files from being committed.
3127
- Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB).
3228
- If `git-lfs` is installed, lfs files will be skipped
@@ -86,7 +82,6 @@ Add this to your `.pre-commit-config.yaml`
8682
`master` is the default if no argument is set.
8783
- `-b` / `--branch` may be specified multiple times to protect multiple
8884
branches.
89-
- `pyflakes` - Run pyflakes on your python files.
9085
- `pretty-format-json` - Checks that all your JSON files are pretty. "Pretty"
9186
here means that keys are sorted and indented. You can configure this with
9287
the following commandline options:
@@ -102,6 +97,12 @@ Add this to your `.pre-commit-config.yaml`
10297
by your markdownfiles). If for some reason you want to treat all files
10398
as markdown, use `--markdown-linebreak-ext=*`.
10499

100+
### Deprecated / replaced hooks
101+
102+
- `autopep8-wrapper`: instead use
103+
[mirrors-autopep8](https://github.com/pre-commit/mirrors-autopep8)
104+
- `pyflakes`: instead use `flake8`
105+
105106
### As a standalone package
106107

107108
If you'd like to use these hooks, they're also available as a standalone

pre_commit_hooks/autopep8_wrapper.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,12 @@
22
from __future__ import print_function
33
from __future__ import unicode_literals
44

5-
import io
6-
import sys
7-
8-
import autopep8
9-
105

116
def main(argv=None):
12-
argv = argv if argv is not None else sys.argv[1:]
13-
args = autopep8.parse_args(argv, apply_config=True)
14-
15-
retv = 0
16-
for filename in args.files:
17-
with io.open(filename, encoding='UTF-8') as f:
18-
original_contents = f.read()
19-
new_contents = autopep8.fix_code(original_contents, args)
20-
if original_contents != new_contents:
21-
print('Fixing {}'.format(filename))
22-
retv = 1
23-
with io.open(filename, 'w', encoding='UTF-8') as output_file:
24-
output_file.write(new_contents)
25-
26-
return retv
7+
raise SystemExit(
8+
'autopep8-wrapper is deprecated. Instead use autopep8 directly via '
9+
'https://github.com/pre-commit/mirrors-autopep8',
10+
)
2711

2812

2913
if __name__ == '__main__':

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
packages=find_packages(exclude=('tests*', 'testing*')),
2626
install_requires=[
27-
# quickfix to prevent pycodestyle conflicts
28-
'flake8!=2.5.3',
29-
'autopep8>=1.3',
27+
'flake8',
3028
'pyyaml',
3129
'six',
3230
],

tests/autopep8_wrapper_test.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,8 @@
66
from pre_commit_hooks.autopep8_wrapper import main
77

88

9-
@pytest.mark.parametrize(
10-
('input_src', 'expected_ret', 'output_src'),
11-
(
12-
('print(1 + 2)\n', 1, 'print(1 + 2)\n'),
13-
('print(1 + 2)\n', 0, 'print(1 + 2)\n'),
14-
),
15-
)
16-
def test_main_failing(tmpdir, input_src, expected_ret, output_src):
17-
path = tmpdir.join('test.py')
18-
path.write(input_src)
19-
ret = main([path.strpath, '-i', '-v'])
20-
assert ret == expected_ret
21-
assert path.read() == output_src
22-
23-
24-
def test_respects_config_file(tmpdir):
25-
with tmpdir.as_cwd():
26-
tmpdir.join('setup.cfg').write('[pycodestyle]\nignore=E221')
27-
tmpdir.join('test.py').write('print(1 + 2)\n')
28-
assert main(['test.py', '-i', '-v']) == 0
9+
def test_invariantly_fails():
10+
with pytest.raises(SystemExit) as excinfo:
11+
main()
12+
msg, = excinfo.value.args
13+
assert 'https://github.com/pre-commit/mirrors-autopep8' in msg

0 commit comments

Comments
 (0)