Skip to content

Commit 990dc5a

Browse files
committed
Merge pull request #510 from PyCQA/package-pycodestyle
Package pycodestyle
2 parents c98b72f + ccc7f14 commit 990dc5a

File tree

12 files changed

+158
-136
lines changed

12 files changed

+158
-136
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ install:
1414
- pip install -e .
1515
- pip list
1616
script:
17-
- python pep8.py --testsuite testsuite
18-
- python pep8.py --statistics pep8.py
19-
- python pep8.py --doctest
17+
- python pycodestyle.py --testsuite testsuite
18+
- python pycodestyle.py --statistics pycodestyle.py
19+
- python pycodestyle.py --doctest
2020
- python setup.py test
2121

2222
notifications:

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
test :
2-
python pep8.py --testsuite testsuite
2+
python pycodestyle.py --testsuite testsuite
33

44
selftest :
5-
python pep8.py --statistics pep8.py
5+
python pycodestyle.py --statistics pycodestyle.py
66

77
doctest :
8-
python pep8.py --doctest
8+
python pycodestyle.py --doctest
99

1010
unittest :
1111
python -m testsuite.test_all

docs/advanced.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ can be highly useful for automated testing of coding style conformance
1313
in your project::
1414

1515
import unittest
16-
import pep8
16+
import pycodestyle
1717

1818

1919
class TestCodeFormat(unittest.TestCase):
2020

2121
def test_pep8_conformance(self):
2222
"""Test that we conform to PEP8."""
23-
pep8style = pep8.StyleGuide(quiet=True)
23+
pep8style = pycodestyle.StyleGuide(quiet=True)
2424
result = pep8style.check_files(['file1.py', 'file2.py'])
2525
self.assertEqual(result.total_errors, 0,
2626
"Found code style errors (and warnings).")
@@ -30,9 +30,9 @@ since Nose suppresses stdout.
3030

3131
There's also a shortcut for checking a single file::
3232

33-
import pep8
33+
import pycodestyle
3434

35-
fchecker = pep8.Checker('testsuite/E27.py', show_source=True)
35+
fchecker = pycodestyle.Checker('testsuite/E27.py', show_source=True)
3636
file_errors = fchecker.check_all()
3737

3838
print("Found %s errors (and warnings)" % file_errors)
@@ -46,13 +46,13 @@ You can configure automated ``pep8`` tests in a variety of ways.
4646
For example, you can pass in a path to a configuration file that ``pep8``
4747
should use::
4848

49-
import pep8
49+
import pycodestyle
5050

51-
pep8style = pep8.StyleGuide(config_file='/path/to/tox.ini')
51+
pep8style = pycodestyle.StyleGuide(config_file='/path/to/tox.ini')
5252

5353
You can also set specific options explicitly::
5454

55-
pep8style = pep8.StyleGuide(ignore=['E501'])
55+
pep8style = pycodestyle.StyleGuide(ignore=['E501'])
5656

5757

5858
Skip file header
@@ -64,19 +64,19 @@ at the beginning and the end of a file. This use case is easy to implement
6464
through a custom wrapper for the PEP 8 library::
6565

6666
#!python
67-
import pep8
67+
import pycodestyle
6868

6969
LINES_SLICE = slice(14, -20)
7070

71-
class PEP8(pep8.StyleGuide):
72-
"""This subclass of pep8.StyleGuide will skip the first and last lines
71+
class PEP8(pycodestyle.StyleGuide):
72+
"""This subclass of pycodestyle.StyleGuide will skip the first and last lines
7373
of each file."""
7474

7575
def input_file(self, filename, lines=None, expected=None, line_offset=0):
7676
if lines is None:
7777
assert line_offset == 0
7878
line_offset = LINES_SLICE.start or 0
79-
lines = pep8.readlines(filename)[LINES_SLICE]
79+
lines = pycodestyle.readlines(filename)[LINES_SLICE]
8080
return super(PEP8, self).input_file(
8181
filename, lines=lines, expected=expected, line_offset=line_offset)
8282

pep8.py renamed to pycodestyle.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
2-
# pep8.py - Check Python source code formatting, according to PEP 8
2+
# pycodestyle.py - Check Python source code formatting, according to PEP 8
3+
#
34
# Copyright (C) 2006-2009 Johann C. Rocholl <[email protected]>
45
# Copyright (C) 2009-2014 Florent Xicluna <[email protected]>
56
# Copyright (C) 2014-2016 Ian Lee <[email protected]>
@@ -28,7 +29,7 @@
2829
Check Python source code formatting, according to PEP 8.
2930
3031
For usage and a list of options, try this:
31-
$ python pep8.py -h
32+
$ python pycodestyle.py -h
3233
3334
This program and its regression test suite live here:
3435
https://github.com/pycqa/pycodestyle
@@ -2158,14 +2159,14 @@ def _main():
21582159
except AttributeError:
21592160
pass # not supported on Windows
21602161

2161-
pep8style = StyleGuide(parse_argv=True)
2162-
options = pep8style.options
2162+
style_guide = StyleGuide(parse_argv=True)
2163+
options = style_guide.options
21632164

21642165
if options.doctest or options.testsuite:
21652166
from testsuite.support import run_tests
2166-
report = run_tests(pep8style)
2167+
report = run_tests(style_guide)
21672168
else:
2168-
report = pep8style.check_files()
2169+
report = style_guide.check_files()
21692170

21702171
if options.statistics:
21712172
report.print_statistics()
@@ -2181,5 +2182,20 @@ def _main():
21812182
sys.stderr.write(str(report.total_errors) + '\n')
21822183
sys.exit(1)
21832184

2185+
2186+
def _main_pep8():
2187+
"""Entrypoint for pep8 commandline tool.
2188+
2189+
Warn of deprecation and advise users to switch to pycodestyle.
2190+
"""
2191+
print(
2192+
'Deprecation Warning:\n'
2193+
'pep8 has been renamed to pycodestyle and the use of the pep8 '
2194+
'executable will be removed in a future release. Please use '
2195+
'`pycodestyle` instead.\n'
2196+
)
2197+
_main()
2198+
2199+
21842200
if __name__ == '__main__':
21852201
_main()

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def get_version():
7-
with open('pep8.py') as f:
7+
with open('pycodestyle.py') as f:
88
for line in f:
99
if line.startswith('__version__'):
1010
return eval(line.split('=')[-1])
@@ -19,16 +19,16 @@ def get_long_description():
1919

2020

2121
setup(
22-
name='pep8',
22+
name='pycodestyle',
2323
version=get_version(),
2424
description="Python style guide checker",
2525
long_description=get_long_description(),
26-
keywords='pep8',
26+
keywords='pycodestyle, pep8, PEP 8, PEP-8, PEP8',
2727
author='Johann C. Rocholl',
2828
author_email='[email protected]',
2929
url='http://pep8.readthedocs.org/',
3030
license='Expat license',
31-
py_modules=['pep8'],
31+
py_modules=['pycodestyle'],
3232
namespace_packages=[],
3333
include_package_data=True,
3434
zip_safe=False,
@@ -38,7 +38,8 @@ def get_long_description():
3838
],
3939
entry_points={
4040
'console_scripts': [
41-
'pep8 = pep8:_main',
41+
'pycodestyle = pycodestyle:_main',
42+
'pep8 = pycodestyle:_main_pep8',
4243
],
4344
},
4445
classifiers=[

testsuite/support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
import sys
55

6-
from pep8 import Checker, BaseReport, StandardReport, readlines
6+
from pycodestyle import Checker, BaseReport, StandardReport, readlines
77

88
SELFTEST_REGEX = re.compile(r'\b(Okay|[EW]\d{3}):\s(.*)')
99
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
@@ -119,7 +119,7 @@ def selftest(options):
119119
print("%s: %s" % (code, source))
120120
else:
121121
count_failed += 1
122-
print("pep8.py: %s:" % error)
122+
print("pycodestyle.py: %s:" % error)
123123
for line in checker.lines:
124124
print(line.rstrip())
125125
return count_failed, count_all

testsuite/test_all.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@
44
import sys
55
import unittest
66

7-
import pep8
7+
import pycodestyle
88
from testsuite.support import init_tests, selftest, ROOT_DIR
99

1010
# Note: please only use a subset of unittest methods which were present
1111
# in Python 2.5: assert(True|False|Equal|NotEqual|Raises)
1212

1313

14-
class Pep8TestCase(unittest.TestCase):
14+
class PycodestyleTestCase(unittest.TestCase):
1515
"""Test the standard errors and warnings (E and W)."""
1616

1717
def setUp(self):
18-
self._style = pep8.StyleGuide(
18+
self._style = pycodestyle.StyleGuide(
1919
paths=[os.path.join(ROOT_DIR, 'testsuite')],
2020
select='E,W', quiet=True)
2121

2222
def test_doctest(self):
2323
import doctest
24-
fail_d, done_d = doctest.testmod(pep8, verbose=False, report=False)
24+
fail_d, done_d = doctest.testmod(
25+
pycodestyle, verbose=False, report=False
26+
)
2527
self.assertTrue(done_d, msg='tests not found')
2628
self.assertFalse(fail_d, msg='%s failure(s)' % fail_d)
2729

@@ -37,9 +39,9 @@ def test_checkers_testsuite(self):
3739
msg='%s failure(s)' % report.total_errors)
3840

3941
def test_own_dog_food(self):
40-
files = [pep8.__file__.rstrip('oc'), __file__.rstrip('oc'),
42+
files = [pycodestyle.__file__.rstrip('oc'), __file__.rstrip('oc'),
4143
os.path.join(ROOT_DIR, 'setup.py')]
42-
report = self._style.init_report(pep8.StandardReport)
44+
report = self._style.init_report(pycodestyle.StandardReport)
4345
report = self._style.check_files(files)
4446
self.assertFalse(report.total_errors,
4547
msg='Failures: %s' % report.messages)
@@ -49,7 +51,7 @@ def suite():
4951
from testsuite import test_api, test_parser, test_shell, test_util
5052

5153
suite = unittest.TestSuite()
52-
suite.addTest(unittest.makeSuite(Pep8TestCase))
54+
suite.addTest(unittest.makeSuite(PycodestyleTestCase))
5355
suite.addTest(unittest.makeSuite(test_api.APITestCase))
5456
suite.addTest(unittest.makeSuite(test_parser.ParserTestCase))
5557
suite.addTest(unittest.makeSuite(test_shell.ShellTestCase))

0 commit comments

Comments
 (0)