@@ -13,14 +13,14 @@ can be highly useful for automated testing of coding style conformance
13
13
in your project::
14
14
15
15
import unittest
16
- import pep8
16
+ import pycodestyle
17
17
18
18
19
19
class TestCodeFormat(unittest.TestCase):
20
20
21
21
def test_pep8_conformance(self):
22
22
"""Test that we conform to PEP8."""
23
- pep8style = pep8 .StyleGuide(quiet=True)
23
+ pep8style = pycodestyle .StyleGuide(quiet=True)
24
24
result = pep8style.check_files(['file1.py', 'file2.py'])
25
25
self.assertEqual(result.total_errors, 0,
26
26
"Found code style errors (and warnings).")
@@ -30,9 +30,9 @@ since Nose suppresses stdout.
30
30
31
31
There's also a shortcut for checking a single file::
32
32
33
- import pep8
33
+ import pycodestyle
34
34
35
- fchecker = pep8 .Checker('testsuite/E27.py', show_source=True)
35
+ fchecker = pycodestyle .Checker('testsuite/E27.py', show_source=True)
36
36
file_errors = fchecker.check_all()
37
37
38
38
print("Found %s errors (and warnings)" % file_errors)
@@ -46,13 +46,13 @@ You can configure automated ``pep8`` tests in a variety of ways.
46
46
For example, you can pass in a path to a configuration file that ``pep8 ``
47
47
should use::
48
48
49
- import pep8
49
+ import pycodestyle
50
50
51
- pep8style = pep8 .StyleGuide(config_file='/path/to/tox.ini')
51
+ pep8style = pycodestyle .StyleGuide(config_file='/path/to/tox.ini')
52
52
53
53
You can also set specific options explicitly::
54
54
55
- pep8style = pep8 .StyleGuide(ignore=['E501'])
55
+ pep8style = pycodestyle .StyleGuide(ignore=['E501'])
56
56
57
57
58
58
Skip file header
@@ -64,19 +64,19 @@ at the beginning and the end of a file. This use case is easy to implement
64
64
through a custom wrapper for the PEP 8 library::
65
65
66
66
#!python
67
- import pep8
67
+ import pycodestyle
68
68
69
69
LINES_SLICE = slice(14, -20)
70
70
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
73
73
of each file."""
74
74
75
75
def input_file(self, filename, lines=None, expected=None, line_offset=0):
76
76
if lines is None:
77
77
assert line_offset == 0
78
78
line_offset = LINES_SLICE.start or 0
79
- lines = pep8 .readlines(filename)[LINES_SLICE]
79
+ lines = pycodestyle .readlines(filename)[LINES_SLICE]
80
80
return super(PEP8, self).input_file(
81
81
filename, lines=lines, expected=expected, line_offset=line_offset)
82
82
0 commit comments