1PYCODESTYLE(1) pycodestyle PYCODESTYLE(1)
2
3
4
6 pycodestyle - pycodestyle documentation
7
8 Python style guide checker
9
10 pycodestyle (formerly pep8) is a tool to check your Python code against
11 some of the style conventions in PEP 8.
12
13 Contents:
14
16 pycodestyle is a tool to check your Python code against some of the
17 style conventions in PEP 8.
18
19 · Features
20
21 · Disclaimer
22
23 · Installation
24
25 · Example usage and output
26
27 · Configuration
28
29 · Error codes
30
31 · Related tools
32
33 Features
34 · Plugin architecture: Adding new checks is easy.
35
36 · Parseable output: Jump to error location in your editor.
37
38 · Small: Just one Python file, requires only stdlib. You can use just
39 the pycodestyle.py file for this purpose.
40
41 · Comes with a comprehensive test suite.
42
43 Disclaimer
44 This utility does not enforce every single rule of PEP 8. It helps to
45 verify that some coding conventions are applied but it does not intend
46 to be exhaustive. Some rules cannot be expressed with a simple algo‐
47 rithm, and other rules are only guidelines which you could circumvent
48 when you need to.
49
50 Always remember this statement from PEP 8:
51 A style guide is about consistency. Consistency with this style
52 guide is important. Consistency within a project is more important.
53 Consistency within one module or function is most important.
54
55 Among other things, these features are currently not in the scope of
56 the pycodestyle library:
57
58 · naming conventions: this kind of feature is supported through plug‐
59 ins. Install flake8 and the pep8-naming extension to use this fea‐
60 ture.
61
62 · docstring conventions: they are not in the scope of this library; see
63 the pydocstyle project.
64
65 · automatic fixing: see the section PEP8 Fixers in the related tools
66 page.
67
68 Installation
69 You can install, upgrade, uninstall pycodestyle.py with these commands:
70
71 $ pip install pycodestyle
72 $ pip install --upgrade pycodestyle
73 $ pip uninstall pycodestyle
74
75 Example usage and output
76 $ pycodestyle --first optparse.py
77 optparse.py:69:11: E401 multiple imports on one line
78 optparse.py:77:1: E302 expected 2 blank lines, found 1
79 optparse.py:88:5: E301 expected 1 blank line, found 0
80 optparse.py:222:34: W602 deprecated form of raising exception
81 optparse.py:347:31: E211 whitespace before '('
82 optparse.py:357:17: E201 whitespace after '{'
83 optparse.py:472:29: E221 multiple spaces before operator
84 optparse.py:544:21: W601 .has_key() is deprecated, use 'in'
85
86 You can also make pycodestyle.py show the source code for each error,
87 and even the relevant text from PEP 8:
88
89 $ pycodestyle --show-source --show-pep8 testsuite/E40.py
90 testsuite/E40.py:2:10: E401 multiple imports on one line
91 import os, sys
92 ^
93 Imports should usually be on separate lines.
94
95 Okay: import os\nimport sys
96 E401: import sys, os
97
98 Or you can display how often each error was found:
99
100 $ pycodestyle --statistics -qq Python-2.5/Lib
101 232 E201 whitespace after '['
102 599 E202 whitespace before ')'
103 631 E203 whitespace before ','
104 842 E211 whitespace before '('
105 2531 E221 multiple spaces before operator
106 4473 E301 expected 1 blank line, found 0
107 4006 E302 expected 2 blank lines, found 1
108 165 E303 too many blank lines (4)
109 325 E401 multiple imports on one line
110 3615 E501 line too long (82 characters)
111 612 W601 .has_key() is deprecated, use 'in'
112 1188 W602 deprecated form of raising exception
113
114 You can also make pycodestyle.py show the error text in different for‐
115 mats by using --format having options default/pylint/custom:
116
117 $ pycodestyle testsuite/E40.py --format=default
118 testsuite/E40.py:2:10: E401 multiple imports on one line
119
120 $ pycodestyle testsuite/E40.py --format=pylint
121 testsuite/E40.py:2: [E401] multiple imports on one line
122
123 $ pycodestyle testsuite/E40.py --format='%(path)s|%(row)d|%(col)d| %(code)s %(text)s'
124 testsuite/E40.py|2|10| E401 multiple imports on one line
125
126 Variables in the custom format option
127
128 ┌─────────┬───────────────┐
129 │Variable │ Significance │
130 └─────────┴───────────────┘
131
132
133 │path │ File name │
134 ├─────────┼───────────────┤
135 │row │ Row number │
136 ├─────────┼───────────────┤
137 │col │ Column number │
138 ├─────────┼───────────────┤
139 │code │ Error code │
140 ├─────────┼───────────────┤
141 │text │ Error text │
142 └─────────┴───────────────┘
143
144 Quick help is available on the command line:
145
146 $ pycodestyle -h
147 Usage: pycodestyle [options] input ...
148
149 Options:
150 --version show program's version number and exit
151 -h, --help show this help message and exit
152 -v, --verbose print status messages, or debug with -vv
153 -q, --quiet report only file names, or nothing with -qq
154 --first show first occurrence of each error
155 --exclude=patterns exclude files or directories which match these comma
156 separated patterns (default: .svn,CVS,.bzr,.hg,.git)
157 --filename=patterns when parsing directories, only check filenames matching
158 these comma separated patterns (default: *.py)
159 --select=errors select errors and warnings (e.g. E,W6)
160 --ignore=errors skip errors and warnings (e.g. E4,W)
161 --show-source show source code for each error
162 --show-pep8 show text of PEP 8 for each error (implies --first)
163 --statistics count errors and warnings
164 --count print total number of errors and warnings to standard
165 error and set exit code to 1 if total is not null
166 --max-line-length=n set maximum allowed line length (default: 79)
167 --hang-closing hang closing bracket instead of matching indentation of
168 opening bracket's line
169 --format=format set the error format [default|pylint|<custom>]
170 --diff report only lines changed according to the unified diff
171 received on STDIN
172
173 Testing Options:
174 --benchmark measure processing speed
175
176 Configuration:
177 The project options are read from the [pycodestyle] section of the
178 tox.ini file or the setup.cfg file located in any parent folder of the
179 path(s) being processed. Allowed options are: exclude, filename, select,
180 ignore, max-line-length, hang-closing, count, format, quiet, show-pep8,
181 show-source, statistics, verbose.
182
183 --config=path user config file location
184 (default: ~/.config/pycodestyle)
185
186 Configuration
187 The behaviour may be configured at two levels, the user and project
188 levels.
189
190 At the user level, settings are read from the following locations:
191
192 If on Windows:
193 ~\.pycodestyle
194
195 Otherwise, if the XDG_CONFIG_HOME environment variable is defined:
196 XDG_CONFIG_HOME/pycodestyle
197
198 Else if XDG_CONFIG_HOME is not defined:
199 ~/.config/pycodestyle
200
201 Example:
202
203 [pycodestyle]
204 count = False
205 ignore = E226,E302,E41
206 max-line-length = 160
207 statistics = True
208
209 At the project level, a setup.cfg file or a tox.ini file is read if
210 present. If none of these files have a [pycodestyle] section, no
211 project specific configuration is loaded.
212
213 Error codes
214 This is the current list of error and warning codes:
215
216 ┌──────────┬────────────────────────────┐
217 │code │ sample message │
218 ├──────────┼────────────────────────────┤
219 │E1 │ Indentation │
220 ├──────────┼────────────────────────────┤
221 │E101 │ indentation contains mixed │
222 │ │ spaces and tabs │
223 ├──────────┼────────────────────────────┤
224 │E111 │ indentation is not a mul‐ │
225 │ │ tiple of four │
226 ├──────────┼────────────────────────────┤
227 │E112 │ expected an indented block │
228 ├──────────┼────────────────────────────┤
229 │E113 │ unexpected indentation │
230 ├──────────┼────────────────────────────┤
231 │E114 │ indentation is not a mul‐ │
232 │ │ tiple of four (comment) │
233 ├──────────┼────────────────────────────┤
234 │E115 │ expected an indented block │
235 │ │ (comment) │
236 ├──────────┼────────────────────────────┤
237 │E116 │ unexpected indentation │
238 │ │ (comment) │
239 ├──────────┼────────────────────────────┤
240 │ │ │
241 ├──────────┼────────────────────────────┤
242 │E121 (*^) │ continuation line │
243 │ │ under-indented for hanging │
244 │ │ indent │
245 ├──────────┼────────────────────────────┤
246 │E122 (^) │ continuation line missing │
247 │ │ indentation or outdented │
248 ├──────────┼────────────────────────────┤
249 │E123 (*) │ closing bracket does not │
250 │ │ match indentation of open‐ │
251 │ │ ing bracket's line │
252 ├──────────┼────────────────────────────┤
253 │E124 (^) │ closing bracket does not │
254 │ │ match visual indentation │
255 ├──────────┼────────────────────────────┤
256 │E125 (^) │ continuation line with │
257 │ │ same indent as next logi‐ │
258 │ │ cal line │
259 ├──────────┼────────────────────────────┤
260 │E126 (*^) │ continuation line │
261 │ │ over-indented for hanging │
262 │ │ indent │
263 ├──────────┼────────────────────────────┤
264 │E127 (^) │ continuation line │
265 │ │ over-indented for visual │
266 │ │ indent │
267 └──────────┴────────────────────────────┘
268
269 │E128 (^) │ continuation line │
270 │ │ under-indented for visual │
271 │ │ indent │
272 ├──────────┼────────────────────────────┤
273 │E129 (^) │ visually indented line │
274 │ │ with same indent as next │
275 │ │ logical line │
276 ├──────────┼────────────────────────────┤
277 │E131 (^) │ continuation line │
278 │ │ unaligned for hanging │
279 │ │ indent │
280 ├──────────┼────────────────────────────┤
281 │E133 (*) │ closing bracket is missing │
282 │ │ indentation │
283 ├──────────┼────────────────────────────┤
284 │ │ │
285 ├──────────┼────────────────────────────┤
286 │E2 │ Whitespace │
287 ├──────────┼────────────────────────────┤
288 │E201 │ whitespace after '(' │
289 ├──────────┼────────────────────────────┤
290 │E202 │ whitespace before ')' │
291 ├──────────┼────────────────────────────┤
292 │E203 │ whitespace before ':' │
293 ├──────────┼────────────────────────────┤
294 │ │ │
295 ├──────────┼────────────────────────────┤
296 │E211 │ whitespace before '(' │
297 ├──────────┼────────────────────────────┤
298 │ │ │
299 ├──────────┼────────────────────────────┤
300 │E221 │ multiple spaces before │
301 │ │ operator │
302 ├──────────┼────────────────────────────┤
303 │E222 │ multiple spaces after │
304 │ │ operator │
305 ├──────────┼────────────────────────────┤
306 │E223 │ tab before operator │
307 ├──────────┼────────────────────────────┤
308 │E224 │ tab after operator │
309 ├──────────┼────────────────────────────┤
310 │E225 │ missing whitespace around │
311 │ │ operator │
312 ├──────────┼────────────────────────────┤
313 │E226 (*) │ missing whitespace around │
314 │ │ arithmetic operator │
315 ├──────────┼────────────────────────────┤
316 │E227 │ missing whitespace around │
317 │ │ bitwise or shift operator │
318 ├──────────┼────────────────────────────┤
319 │E228 │ missing whitespace around │
320 │ │ modulo operator │
321 ├──────────┼────────────────────────────┤
322 │ │ │
323 ├──────────┼────────────────────────────┤
324 │E231 │ missing whitespace after │
325 │ │ ',', ';', or ':' │
326 ├──────────┼────────────────────────────┤
327 │ │ │
328 ├──────────┼────────────────────────────┤
329 │E241 (*) │ multiple spaces after ',' │
330 ├──────────┼────────────────────────────┤
331 │E242 (*) │ tab after ',' │
332 ├──────────┼────────────────────────────┤
333 │ │ │
334 └──────────┴────────────────────────────┘
335
336
337 │E251 │ unexpected spaces around │
338 │ │ keyword / parameter equals │
339 ├──────────┼────────────────────────────┤
340 │ │ │
341 ├──────────┼────────────────────────────┤
342 │E261 │ at least two spaces before │
343 │ │ inline comment │
344 ├──────────┼────────────────────────────┤
345 │E262 │ inline comment should │
346 │ │ start with '# ' │
347 ├──────────┼────────────────────────────┤
348 │E265 │ block comment should start │
349 │ │ with '# ' │
350 ├──────────┼────────────────────────────┤
351 │E266 │ too many leading '#' for │
352 │ │ block comment │
353 ├──────────┼────────────────────────────┤
354 │ │ │
355 ├──────────┼────────────────────────────┤
356 │E271 │ multiple spaces after key‐ │
357 │ │ word │
358 ├──────────┼────────────────────────────┤
359 │E272 │ multiple spaces before │
360 │ │ keyword │
361 ├──────────┼────────────────────────────┤
362 │E273 │ tab after keyword │
363 ├──────────┼────────────────────────────┤
364 │E274 │ tab before keyword │
365 ├──────────┼────────────────────────────┤
366 │E275 │ missing whitespace after │
367 │ │ keyword │
368 ├──────────┼────────────────────────────┤
369 │ │ │
370 ├──────────┼────────────────────────────┤
371 │E3 │ Blank line │
372 ├──────────┼────────────────────────────┤
373 │E301 │ expected 1 blank line, │
374 │ │ found 0 │
375 ├──────────┼────────────────────────────┤
376 │E302 │ expected 2 blank lines, │
377 │ │ found 0 │
378 ├──────────┼────────────────────────────┤
379 │E303 │ too many blank lines (3) │
380 ├──────────┼────────────────────────────┤
381 │E304 │ blank lines found after │
382 │ │ function decorator │
383 ├──────────┼────────────────────────────┤
384 │E305 │ expected 2 blank lines │
385 │ │ after end of function or │
386 │ │ class │
387 ├──────────┼────────────────────────────┤
388 │E306 │ expected 1 blank line │
389 │ │ before a nested definition │
390 ├──────────┼────────────────────────────┤
391 │ │ │
392 ├──────────┼────────────────────────────┤
393 │E4 │ Import │
394 ├──────────┼────────────────────────────┤
395 │E401 │ multiple imports on one │
396 │ │ line │
397 ├──────────┼────────────────────────────┤
398 │E402 │ module level import not at │
399 │ │ top of file │
400 ├──────────┼────────────────────────────┤
401 │ │ │
402 └──────────┴────────────────────────────┘
403
404
405 │E5 │ Line length │
406 ├──────────┼────────────────────────────┤
407 │E501 (^) │ line too long (82 > 79 │
408 │ │ characters) │
409 ├──────────┼────────────────────────────┤
410 │E502 │ the backslash is redundant │
411 │ │ between brackets │
412 ├──────────┼────────────────────────────┤
413 │ │ │
414 ├──────────┼────────────────────────────┤
415 │E7 │ Statement │
416 ├──────────┼────────────────────────────┤
417 │E701 │ multiple statements on one │
418 │ │ line (colon) │
419 ├──────────┼────────────────────────────┤
420 │E702 │ multiple statements on one │
421 │ │ line (semicolon) │
422 ├──────────┼────────────────────────────┤
423 │E703 │ statement ends with a │
424 │ │ semicolon │
425 ├──────────┼────────────────────────────┤
426 │E704 (*) │ multiple statements on one │
427 │ │ line (def) │
428 ├──────────┼────────────────────────────┤
429 │E711 (^) │ comparison to None should │
430 │ │ be 'if cond is None:' │
431 ├──────────┼────────────────────────────┤
432 │E712 (^) │ comparison to True should │
433 │ │ be 'if cond is True:' or │
434 │ │ 'if cond:' │
435 ├──────────┼────────────────────────────┤
436 │E713 │ test for membership should │
437 │ │ be 'not in' │
438 ├──────────┼────────────────────────────┤
439 │E714 │ test for object identity │
440 │ │ should be 'is not' │
441 ├──────────┼────────────────────────────┤
442 │E721 (^) │ do not compare types, use │
443 │ │ 'isinstance()' │
444 ├──────────┼────────────────────────────┤
445 │E722 │ do not use bare except, │
446 │ │ specify exception instead │
447 ├──────────┼────────────────────────────┤
448 │E731 │ do not assign a lambda │
449 │ │ expression, use a def │
450 ├──────────┼────────────────────────────┤
451 │E741 │ do not use variables named │
452 │ │ 'l', 'O', or 'I' │
453 ├──────────┼────────────────────────────┤
454 │E742 │ do not define classes │
455 │ │ named 'l', 'O', or 'I' │
456 ├──────────┼────────────────────────────┤
457 │E743 │ do not define functions │
458 │ │ named 'l', 'O', or 'I' │
459 ├──────────┼────────────────────────────┤
460 │ │ │
461 ├──────────┼────────────────────────────┤
462 │E9 │ Runtime │
463 ├──────────┼────────────────────────────┤
464 │E901 │ SyntaxError or Indenta‐ │
465 │ │ tionError │
466 ├──────────┼────────────────────────────┤
467 │E902 │ IOError │
468 ├──────────┼────────────────────────────┤
469 │ │ │
470 └──────────┴────────────────────────────┘
471
472
473 │W1 │ Indentation warning │
474 ├──────────┼────────────────────────────┤
475 │W191 │ indentation contains tabs │
476 ├──────────┼────────────────────────────┤
477 │ │ │
478 ├──────────┼────────────────────────────┤
479 │W2 │ Whitespace warning │
480 ├──────────┼────────────────────────────┤
481 │W291 │ trailing whitespace │
482 ├──────────┼────────────────────────────┤
483 │W292 │ no newline at end of file │
484 ├──────────┼────────────────────────────┤
485 │W293 │ blank line contains white‐ │
486 │ │ space │
487 ├──────────┼────────────────────────────┤
488 │ │ │
489 ├──────────┼────────────────────────────┤
490 │W3 │ Blank line warning │
491 ├──────────┼────────────────────────────┤
492 │W391 │ blank line at end of file │
493 ├──────────┼────────────────────────────┤
494 │ │ │
495 ├──────────┼────────────────────────────┤
496 │W5 │ Line break warning │
497 ├──────────┼────────────────────────────┤
498 │W503 (*) │ line break before binary │
499 │ │ operator │
500 ├──────────┼────────────────────────────┤
501 │W504 (*) │ line break after binary │
502 │ │ operator │
503 ├──────────┼────────────────────────────┤
504 │ │ │
505 ├──────────┼────────────────────────────┤
506 │W6 │ Deprecation warning │
507 ├──────────┼────────────────────────────┤
508 │W601 │ .has_key() is deprecated, │
509 │ │ use 'in' │
510 ├──────────┼────────────────────────────┤
511 │W602 │ deprecated form of raising │
512 │ │ exception │
513 ├──────────┼────────────────────────────┤
514 │W603 │ '<>' is deprecated, use │
515 │ │ '!=' │
516 ├──────────┼────────────────────────────┤
517 │W604 │ backticks are deprecated, │
518 │ │ use 'repr()' │
519 ├──────────┼────────────────────────────┤
520 │W605 │ invalid escape sequence │
521 │ │ 'x' │
522 ├──────────┼────────────────────────────┤
523 │W606 │ 'async' and 'await' are │
524 │ │ reserved keywords starting │
525 │ │ with Python 3.7 │
526 └──────────┴────────────────────────────┘
527
528 (*) In the default configuration, the checks E121, E123, E126, E133,
529 E226, E241, E242, E704, W503 and W504 are ignored because they are not
530 rules unanimously accepted, and PEP 8 does not enforce them. The check
531 W503 is mutually exclusive with check W504. The check E133 is mutually
532 exclusive with check E123. Use switch --hang-closing to report E133
533 instead of E123.
534
535 (^) These checks can be disabled at the line level using the # noqa
536 special comment. This possibility should be reserved for special
537 cases.
538 Special cases aren't special enough to break the rules.
539
540 Note: most errors can be listed with such one-liner:
541
542 $ python pycodestyle.py --first --select E,W testsuite/ --format '%(code)s: %(text)s'
543
544 Related tools
545 The flake8 checker is a wrapper around pycodestyle and similar tools.
546 It supports plugins.
547
548 Other tools which use pycodestyle are referenced in the Wiki: list of
549 related tools.
550
552 Automated tests
553 You can also execute pycodestyle tests from Python code. For example,
554 this can be highly useful for automated testing of coding style confor‐
555 mance in your project:
556
557 import unittest
558 import pycodestyle
559
560
561 class TestCodeFormat(unittest.TestCase):
562
563 def test_conformance(self):
564 """Test that we conform to PEP-8."""
565 style = pycodestyle.StyleGuide(quiet=True)
566 result = style.check_files(['file1.py', 'file2.py'])
567 self.assertEqual(result.total_errors, 0,
568 "Found code style errors (and warnings).")
569
570 If you are using nosetests for running tests, remove quiet=True since
571 Nose suppresses stdout.
572
573 There's also a shortcut for checking a single file:
574
575 import pycodestyle
576
577 fchecker = pycodestyle.Checker('testsuite/E27.py', show_source=True)
578 file_errors = fchecker.check_all()
579
580 print("Found %s errors (and warnings)" % file_errors)
581
582 Configuring tests
583 You can configure automated pycodestyle tests in a variety of ways.
584
585 For example, you can pass in a path to a configuration file that
586 pycodestyle should use:
587
588 import pycodestyle
589
590 style = pycodestyle.StyleGuide(config_file='/path/to/tox.ini')
591
592 You can also set specific options explicitly:
593
594 style = pycodestyle.StyleGuide(ignore=['E501'])
595
596 Skip file header
597 Another example is related to the feature request #143: skip a number
598 of lines at the beginning and the end of a file. This use case is easy
599 to implement through a custom wrapper for the PEP 8 library:
600
601 #!python
602 import pycodestyle
603
604 LINES_SLICE = slice(14, -20)
605
606 class StyleGuide(pycodestyle.StyleGuide):
607 """This subclass of pycodestyle.StyleGuide will skip the first and last lines
608 of each file."""
609
610 def input_file(self, filename, lines=None, expected=None, line_offset=0):
611 if lines is None:
612 assert line_offset == 0
613 line_offset = LINES_SLICE.start or 0
614 lines = pycodestyle.readlines(filename)[LINES_SLICE]
615 return super(StyleGuide, self).input_file(
616 filename, lines=lines, expected=expected, line_offset=line_offset)
617
618 if __name__ == '__main__':
619 style = StyleGuide(parse_argv=True, config_file=True)
620 report = style.check_files()
621 if report.total_errors:
622 raise SystemExit(1)
623
624 This module declares a lines' window which skips 14 lines at the begin‐
625 ning and 20 lines at the end. If there's no line to skip at the end,
626 it could be changed with LINES_SLICE = slice(14, None) for example.
627
628 You can save it in a file and use it with the same options as the orig‐
629 inal pycodestyle.
630
632 The library provides classes which are usable by third party tools.
633
634 · Checker Classes
635
636 · Report Classes
637
638 · Utilities
639
640 Checker Classes
641 The StyleGuide class is used to configure a style guide checker
642 instance to check multiple files.
643
644 The Checker class can be used to check a single file.
645
646 class pycodestyle.StyleGuide(parse_argv=False, config_file=None,
647 parser=None, paths=None, report=None, **kwargs)
648 Initialize a PEP-8 instance with few options.
649
650 init_report(reporter=None)
651 Initialize the report instance.
652
653 check_files(paths=None)
654 Run all checks on the paths.
655
656 input_file(filename, lines=None, expected=None, line_offset=0)
657 Run all checks on a Python source file.
658
659 input_dir(dirname)
660 Check all files in this directory and all subdirectories.
661
662 excluded(filename, parent=None)
663 Check if the file should be excluded.
664
665 Check if 'options.exclude' contains a pattern that
666 matches filename.
667
668 ignore_code(code)
669 Check if the error code should be ignored.
670
671 If 'options.select' contains a prefix of the error code,
672 return False. Else, if 'options.ignore' contains a pre‐
673 fix of the error code, return True.
674
675 get_checks(argument_name)
676 Get all the checks for this category.
677
678 Find all globally visible functions where the first argu‐
679 ment name starts with argument_name and which contain
680 selected tests.
681
682 class pycodestyle.Checker(filename=None, lines=None, report=None,
683 **kwargs)
684 Load a Python source file, tokenize it, check coding style.
685
686 readline()
687 Get the next line from the input buffer.
688
689 run_check(check, argument_names)
690 Run a check plugin.
691
692 check_physical(line)
693 Run all physical checks on a raw input line.
694
695 build_tokens_line()
696 Build a logical line from tokens.
697
698 check_logical()
699 Build a line from tokens and run all logical checks on
700 it.
701
702 check_ast()
703 Build the file's AST and run all AST checks.
704
705 generate_tokens()
706 Tokenize the file, run physical line checks and yield
707 tokens.
708
709 check_all(expected=None, line_offset=0)
710 Run all checks on the input file.
711
712 Report Classes
713 class pycodestyle.BaseReport(options)
714 Collect the results of the checks.
715
716 start()
717 Start the timer.
718
719 stop() Stop the timer.
720
721 init_file(filename, lines, expected, line_offset)
722 Signal a new file.
723
724 increment_logical_line()
725 Signal a new logical line.
726
727 error(line_number, offset, text, check)
728 Report an error, according to options.
729
730 get_file_results()
731 Return the count of errors and warnings for this file.
732
733 get_count(prefix='')
734 Return the total count of errors and warnings.
735
736 get_statistics(prefix='')
737 Get statistics for message codes that start with the pre‐
738 fix.
739
740 prefix='' matches all errors and warnings prefix='E'
741 matches all errors prefix='W' matches all warnings pre‐
742 fix='E4' matches all errors that have to do with imports
743
744 print_statistics(prefix='')
745 Print overall statistics (number of errors and warnings).
746
747 print_benchmark()
748 Print benchmark numbers.
749
750 class pycodestyle.FileReport(options)
751 Collect the results of the checks and print only the filenames.
752
753 class pycodestyle.StandardReport(options)
754 Collect and print the results of the checks.
755
756 class pycodestyle.DiffReport(options)
757 Collect and print the results for the changed lines only.
758
759 Utilities
760 pycodestyle.expand_indent(line)
761 Return the amount of indentation.
762
763 Tabs are expanded to the next multiple of 8.
764
765 >>> expand_indent(' ')
766 4
767 >>> expand_indent('\t')
768 8
769 >>> expand_indent(' \t')
770 8
771 >>> expand_indent(' \t')
772 16
773
774 pycodestyle.mute_string(text)
775 Replace contents with 'xxx' to prevent syntax matching.
776
777 >>> mute_string('"abc"')
778 '"xxx"'
779 >>> mute_string("'''abc'''")
780 "'''xxx'''"
781 >>> mute_string("r'abc'")
782 "r'xxx'"
783
784 pycodestyle.read_config(options, args, arglist, parser)
785 Read and parse configurations.
786
787 If a config file is specified on the command line with the
788 "--config" option, then only it is used for configuration.
789
790 Otherwise, the user configuration (~/.config/pycodestyle) and
791 any local configurations in the current directory or above will
792 be merged together (in that order) using the read method of Con‐
793 figParser.
794
795 pycodestyle.process_options(arglist=None, parse_argv=False, con‐
796 fig_file=None)
797 Process options passed either via arglist or via command line
798 args.
799
800 Passing in the config_file parameter allows other tools, such as
801 flake8 to specify their own options to be processed in
802 pycodestyle.
803
804 pycodestyle.register_check(func_or_cls, codes=None)
805 Register a new check object.
806
808 Source code
809 The source code is currently available on GitHub under the terms and
810 conditions of the Expat license. Fork away!
811
812 · Source code and issue tracker on GitHub.
813
814 · Continuous tests against Python 2.6 through 3.6 as well as the
815 nightly Python build and PyPy, on Travis CI platform.
816
817 Direction
818 Some high-level aims and directions to bear in mind for contributions:
819
820 · pycodestyle is intended to be as fast as possible. Using the ast
821 module defeats that purpose. The pep8-naming plugin exists for this
822 sort of functionality.
823
824 · If you want to provide extensibility / plugins, please see flake8 -
825 pycodestyle doesn't want or need a plugin architecture.
826
827 · Python 2.6 support is still deemed important.
828
829 · pycodestyle aims to have no external dependencies.
830
831 Contribute
832 You can add checks to this program by writing plugins. Each plugin is
833 a simple function that is called for each line of source code, either
834 physical or logical.
835
836 Physical line:
837
838 · Raw line of text from the input file.
839
840 Logical line:
841
842 · Multi-line statements converted to a single line.
843
844 · Stripped left and right.
845
846 · Contents of strings replaced with "xxx" of same length.
847
848 · Comments removed.
849
850 The check function requests physical or logical lines by the name of
851 the first argument:
852
853 def maximum_line_length(physical_line)
854 def extraneous_whitespace(logical_line)
855 def blank_lines(logical_line, blank_lines, indent_level, line_number)
856
857 The last example above demonstrates how check plugins can request addi‐
858 tional information with extra arguments. All attributes of the Checker
859 object are available. Some examples:
860
861 · lines: a list of the raw lines from the input file
862
863 · tokens: the tokens that contribute to this logical line
864
865 · line_number: line number in the input file
866
867 · total_lines: number of lines in the input file
868
869 · blank_lines: blank lines before this one
870
871 · indent_char: indentation character in this file (" " or "\t")
872
873 · indent_level: indentation (with tabs expanded to multiples of 8)
874
875 · previous_indent_level: indentation on previous line
876
877 · previous_logical: previous logical line
878
879 Check plugins can also maintain per-file state. If you need this,
880 declare a parameter named checker_state. You will be passed a dict,
881 which will be the same one for all lines in the same file but a differ‐
882 ent one for different files. Each check plugin gets its own dict, so
883 you don't need to worry about clobbering the state of other plugins.
884
885 The docstring of each check function shall be the relevant part of text
886 from PEP 8. It is printed if the user enables --show-pep8. Several
887 docstrings contain examples directly from the PEP 8 document.
888
889 Okay: spam(ham[1], {eggs: 2})
890 E201: spam( ham[1], {eggs: 2})
891
892 These examples are verified automatically when pycodestyle.py is run
893 with the --doctest option. You can add examples for your own check
894 functions. The format is simple: "Okay" or error/warning code followed
895 by colon and space, the rest of the line is example source code. If
896 you put 'r' before the docstring, you can use \n for newline and \t for
897 tab.
898
899 Then be sure to pass the tests:
900
901 $ python pycodestyle.py --testsuite testsuite
902 $ python pycodestyle.py --doctest
903 $ python pycodestyle.py --verbose pycodestyle.py
904
905 When contributing to pycodestyle, please observe our Code of Conduct.
906
907 To run the tests, the core developer team and Travis CI use tox:
908
909 $ pip install -r dev-requirements.txt
910 $ tox
911
912 All the tests should pass for all available interpreters, with the sum‐
913 mary of:
914
915 congratulations :)
916
917 Changes
918 2.4.0 (2018-04-10)
919 New checks:
920
921 · Add W504 warning for checking that a break doesn't happen after a
922 binary operator. This check is ignored by default. PR #502.
923
924 · Add W605 warning for invalid escape sequences in string literals. PR
925 #676.
926
927 · Add W606 warning for 'async' and 'await' reserved keywords being
928 introduced in Python 3.7. PR #684.
929
930 · Add E252 error for missing whitespace around equal sign in type anno‐
931 tated function arguments with defaults values. PR #717.
932
933 Changes:
934
935 · An internal bisect search has replaced a linear search in order to
936 improve efficiency. PR #648.
937
938 · pycodestyle now uses PyPI trove classifiers in order to document sup‐
939 ported python versions on PyPI. PR #654.
940
941 · 'setup.cfg' '[wheel]' section has been renamed to '[bdist_wheel]', as
942 the former is legacy. PR #653.
943
944 · pycodestyle now handles very long lines much more efficiently for
945 python 3.2+. Fixes #643. PR #644.
946
947 · You can now write 'pycodestyle.StyleGuide(verbose=True)' instead of
948 'pycodestyle.StyleGuide(verbose=True, paths=['-v'])' in order to
949 achieve verbosity. PR #663.
950
951 · The distribution of pycodestyle now includes the license text in
952 order to comply with open source licenses which require this. PR
953 #694.
954
955 · 'maximum_line_length' now ignores shebang ('#!') lines. PR #736.
956
957 · Add configuration option for the allowed number of blank lines. It is
958 implemented as a top level dictionary which can be easily overwrit‐
959 ten. Fixes #732. PR #733.
960
961 Bugs:
962
963 · Prevent a 'DeprecationWarning', and a 'SyntaxError' in future python,
964 caused by an invalid escape sequence. PR #625.
965
966 · Correctly report E501 when the first line of a docstring is too long.
967 Resolves #622. PR #630.
968
969 · Support variable annotation when variable start by a keyword, such as
970 class variable type annotations in python 3.6. PR #640.
971
972 · pycodestyle internals have been changed in order to allow 'python3 -m
973 cProfile' to report correct metrics. PR #647.
974
975 · Fix a spelling mistake in the description of E722. PR #697.
976
977 · 'pycodestyle --diff' now does not break if your 'gitconfig' enables
978 'mnemonicprefix'. PR #706.
979
980 2.3.1 (2017-01-31)
981 Bugs:
982
983 · Fix regression in detection of E302 and E306; #618, #620
984
985 2.3.0 (2017-01-30)
986 New Checks:
987
988 · Add E722 warning for bare except clauses
989
990 · Report E704 for async function definitions (async def)
991
992 Bugs:
993
994 · Fix another E305 false positive for variables beginning with "class"
995 or "def"
996
997 · Fix detection of multiple spaces between async and def
998
999 · Fix handling of variable annotations. Stop reporting E701 on Python
1000 3.6 for variable annotations.
1001
1002 2.2.0 (2016-11-14)
1003 Announcements:
1004
1005 · Added Make target to obtain proper tarball file permissions; #599
1006
1007 Bugs:
1008
1009 · Fixed E305 regression caused by #400; #593
1010
1011 2.1.0 (2016-11-04)
1012 Announcements:
1013
1014 · Change all references to the pep8 project to say pycodestyle; #530
1015
1016 Changes:
1017
1018 · Report E302 for blank lines before an "async def"; #556
1019
1020 · Update our list of tested and supported Python versions which are
1021 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5 as well as the nightly Python build
1022 and PyPy.
1023
1024 · Report E742 and E743 for functions and classes badly named 'l', 'O',
1025 or 'I'.
1026
1027 · Report E741 on 'global' and 'nonlocal' statements, as well as prohib‐
1028 ited single-letter variables.
1029
1030 · Deprecated use of [pep8] section name in favor of [pycodestyle]; #591
1031
1032 · Report E722 when bare except clause is used; #579
1033
1034 Bugs:
1035
1036 · Fix opt_type AssertionError when using Flake8 2.6.2 and pycodestyle;
1037 #561
1038
1039 · Require two blank lines after toplevel def, class; #536
1040
1041 · Remove accidentally quadratic computation based on the number of
1042 colons. This will make pycodestyle faster in some cases; #314
1043
1044 2.0.0 (2016-05-31)
1045 Announcements:
1046
1047 · Repository renamed to pycodestyle; Issue #466 / #481.
1048
1049 · Added joint Code of Conduct as member of PyCQA; #483
1050
1051 Changes:
1052
1053 · Added tox test support for Python 3.5 and pypy3
1054
1055 · Added check E275 for whitespace on from ... import ... lines; #489 /
1056 #491
1057
1058 · Added W503 to the list of codes ignored by default ignore list; #498
1059
1060 · Removed use of project level .pep8 configuration file; #364
1061
1062 Bugs:
1063
1064 · Fixed bug with treating ~ operator as binary; #383 / #384
1065
1066 · Identify binary operators as unary; #484 / #485
1067
1068 1.7.0 (2016-01-12)
1069 Announcements:
1070
1071 · Repository moved to PyCQA Organization on GitHub:
1072 https://github.com/pycqa/pep8
1073
1074 Changes:
1075
1076 · Reverted the fix in #368, "options passed on command line are only
1077 ones accepted" feature. This has many unintended consequences in pep8
1078 and flake8 and needs to be reworked when I have more time.
1079
1080 · Added support for Python 3.5. (Issue #420 & #459)
1081
1082 · Added support for multi-line config_file option parsing. (Issue #429)
1083
1084 · Improved parameter parsing. (Issues #420 & #456)
1085
1086 Bugs:
1087
1088 · Fixed BytesWarning on Python 3. (Issue #459)
1089
1090 1.6.2 (2015-02-15)
1091 Changes:
1092
1093 · Added check for breaking around a binary operator. (Issue #197, Pull
1094 #305)
1095
1096 Bugs:
1097
1098 · Restored config_file parameter in process_options(). (Issue #380)
1099
1100 1.6.1 (2015-02-08)
1101 Changes:
1102
1103 · Assign variables before referenced. (Issue #287)
1104
1105 Bugs:
1106
1107 · Exception thrown due to unassigned local_dir variable. (Issue #377)
1108
1109 1.6.0 (2015-02-06)
1110 News:
1111
1112 · Ian Lee <ianlee1521@gmail.com> joined the project as a maintainer.
1113
1114 Changes:
1115
1116 · Report E731 for lambda assignment. (Issue #277)
1117
1118 · Report E704 for one-liner def instead of E701. Do not report this
1119 error in the default configuration. (Issue #277)
1120
1121 · Replace codes E111, E112 and E113 with codes E114, E115 and E116 for
1122 bad indentation of comments. (Issue #274)
1123
1124 · Report E266 instead of E265 when the block comment starts with multi‐
1125 ple #. (Issue #270)
1126
1127 · Report E402 for import statements not at the top of the file. (Issue
1128 #264)
1129
1130 · Do not enforce whitespaces around ** operator. (Issue #292)
1131
1132 · Strip whitespace from around paths during normalization. (Issue #339
1133 / #343)
1134
1135 · Update --format documentation. (Issue #198 / Pull Request #310)
1136
1137 · Add .tox/ to default excludes. (Issue #335)
1138
1139 · Do not report E121 or E126 in the default configuration. (Issues #256
1140 / #316)
1141
1142 · Allow spaces around the equals sign in an annotated function. (Issue
1143 #357)
1144
1145 · Allow trailing backslash if in an inline comment. (Issue #374)
1146
1147 · If --config is used, only that configuration is processed. Otherwise,
1148 merge the user and local configurations are merged. (Issue #368 /
1149 #369)
1150
1151 Bug fixes:
1152
1153 · Don't crash if Checker.build_tokens_line() returns None. (Issue #306)
1154
1155 · Don't crash if os.path.expanduser() throws an ImportError. (Issue
1156 #297)
1157
1158 · Missing space around keyword parameter equal not always reported,
1159 E251. (Issue #323)
1160
1161 · Fix false positive E711/E712/E713. (Issues #330 and #336)
1162
1163 · Do not skip physical checks if the newline is escaped. (Issue #319)
1164
1165 · Flush sys.stdout to avoid race conditions with printing. See flake8
1166 bug: https://gitlab.com/pycqa/flake8/issues/17 for more details.
1167 (Issue #363)
1168
1169 1.5.7 (2014-05-29)
1170 Bug fixes:
1171
1172 · Skip the traceback on "Broken pipe" signal. (Issue #275)
1173
1174 · Do not exit when an option in setup.cfg or tox.ini is not recognized.
1175
1176 · Check the last line even if it does not end with a newline. (Issue
1177 #286)
1178
1179 · Always open files in universal newlines mode in Python 2. (Issue
1180 #288)
1181
1182 1.5.6 (2014-04-14)
1183 Bug fixes:
1184
1185 · Check the last line even if it has no end-of-line. (Issue #273)
1186
1187 1.5.5 (2014-04-10)
1188 Bug fixes:
1189
1190 · Fix regression with E22 checks and inline comments. (Issue #271)
1191
1192 1.5.4 (2014-04-07)
1193 Bug fixes:
1194
1195 · Fix negative offset with E303 before a multi-line docstring. (Issue
1196 #269)
1197
1198 1.5.3 (2014-04-04)
1199 Bug fixes:
1200
1201 · Fix wrong offset computation when error is on the last char of a
1202 physical line. (Issue #268)
1203
1204 1.5.2 (2014-04-04)
1205 Changes:
1206
1207 · Distribute a universal wheel file.
1208
1209 Bug fixes:
1210
1211 · Report correct line number for E303 with comments. (Issue #60)
1212
1213 · Do not allow newline after parameter equal. (Issue #252)
1214
1215 · Fix line number reported for multi-line strings. (Issue #220)
1216
1217 · Fix false positive E121/E126 with multi-line strings. (Issue #265)
1218
1219 · Fix E501 not detected in comments with Python 2.5.
1220
1221 · Fix caret position with --show-source when line contains tabs.
1222
1223 1.5.1 (2014-03-27)
1224 Bug fixes:
1225
1226 · Fix a crash with E125 on multi-line strings. (Issue #263)
1227
1228 1.5 (2014-03-26)
1229 Changes:
1230
1231 · Report E129 instead of E125 for visually indented line with same
1232 indent as next logical line. (Issue #126)
1233
1234 · Report E265 for space before block comment. (Issue #190)
1235
1236 · Report E713 and E714 when operators not in and is not are recom‐
1237 mended. (Issue #236)
1238
1239 · Allow long lines in multiline strings and comments if they cannot be
1240 wrapped. (Issue #224).
1241
1242 · Optionally disable physical line checks inside multiline strings,
1243 using # noqa. (Issue #242)
1244
1245 · Change text for E121 to report "continuation line under-indented for
1246 hanging indent" instead of indentation not being a multiple of 4.
1247
1248 · Report E131 instead of E121 / E126 if the hanging indent is not con‐
1249 sistent within the same continuation block. It helps when error E121
1250 or E126 is in the ignore list.
1251
1252 · Report E126 instead of E121 when the continuation line is hanging
1253 with extra indentation, even if indentation is not a multiple of 4.
1254
1255 Bug fixes:
1256
1257 · Allow the checkers to report errors on empty files. (Issue #240)
1258
1259 · Fix ignoring too many checks when --select is used with codes
1260 declared in a flake8 extension. (Issue #216)
1261
1262 · Fix regression with multiple brackets. (Issue #214)
1263
1264 · Fix StyleGuide to parse the local configuration if the keyword argu‐
1265 ment paths is specified. (Issue #246)
1266
1267 · Fix a false positive E124 for hanging indent. (Issue #254)
1268
1269 · Fix a false positive E126 with embedded colon. (Issue #144)
1270
1271 · Fix a false positive E126 when indenting with tabs. (Issue #204)
1272
1273 · Fix behaviour when exclude is in the configuration file and the cur‐
1274 rent directory is not the project directory. (Issue #247)
1275
1276 · The logical checks can return None instead of an empty iterator.
1277 (Issue #250)
1278
1279 · Do not report multiple E101 if only the first indentation starts with
1280 a tab. (Issue #237)
1281
1282 · Fix a rare false positive W602. (Issue #34)
1283
1284 1.4.6 (2013-07-02)
1285 Changes:
1286
1287 · Honor # noqa for errors E711 and E712. (Issue #180)
1288
1289 · When both a tox.ini and a setup.cfg are present in the project direc‐
1290 tory, merge their contents. The tox.ini file takes precedence (same
1291 as before). (Issue #182)
1292
1293 · Give priority to --select over --ignore. (Issue #188)
1294
1295 · Compare full path when excluding a file. (Issue #186)
1296
1297 · New option --hang-closing to switch to the alternative style of clos‐
1298 ing bracket indentation for hanging indent. Add error E133 for clos‐
1299 ing bracket which is missing indentation. (Issue #103)
1300
1301 · Accept both styles of closing bracket indentation for hanging indent.
1302 Do not report error E123 in the default configuration. (Issue #103)
1303
1304 Bug fixes:
1305
1306 · Do not crash when running AST checks and the document contains null
1307 bytes. (Issue #184)
1308
1309 · Correctly report other E12 errors when E123 is ignored. (Issue #103)
1310
1311 · Fix false positive E261/E262 when the file contains a BOM. (Issue
1312 #193)
1313
1314 · Fix E701, E702 and E703 not detected sometimes. (Issue #196)
1315
1316 · Fix E122 not detected in some cases. (Issue #201 and #208)
1317
1318 · Fix false positive E121 with multiple brackets. (Issue #203)
1319
1320 1.4.5 (2013-03-06)
1321 · When no path is specified, do not try to read from stdin. The fea‐
1322 ture was added in 1.4.3, but it is not supported on Windows. Use -
1323 filename argument to read from stdin. This usage is supported since
1324 1.3.4. (Issue #170)
1325
1326 · Do not require setuptools in setup.py. It works around an issue with
1327 pip and Python 3. (Issue #172)
1328
1329 · Add __pycache__ to the ignore list.
1330
1331 · Change misleading message for E251. (Issue #171)
1332
1333 · Do not report false E302 when the source file has a coding cookie or
1334 a comment on the first line. (Issue #174)
1335
1336 · Reorganize the tests and add tests for the API and for the command
1337 line usage and options. (Issues #161 and #162)
1338
1339 · Ignore all checks which are not explicitly selected when select is
1340 passed to the StyleGuide constructor.
1341
1342 1.4.4 (2013-02-24)
1343 · Report E227 or E228 instead of E225 for whitespace around bitwise,
1344 shift or modulo operators. (Issue #166)
1345
1346 · Change the message for E226 to make clear that it is about arithmetic
1347 operators.
1348
1349 · Fix a false positive E128 for continuation line indentation with
1350 tabs.
1351
1352 · Fix regression with the --diff option. (Issue #169)
1353
1354 · Fix the TestReport class to print the unexpected warnings and errors.
1355
1356 1.4.3 (2013-02-22)
1357 · Hide the --doctest and --testsuite options when installed.
1358
1359 · Fix crash with AST checkers when the syntax is invalid. (Issue #160)
1360
1361 · Read from standard input if no path is specified.
1362
1363 · Initiate a graceful shutdown on Control+C.
1364
1365 · Allow changing the checker_class for the StyleGuide.
1366
1367 1.4.2 (2013-02-10)
1368 · Support AST checkers provided by third-party applications.
1369
1370 · Register new checkers with register_check(func_or_cls, codes).
1371
1372 · Allow constructing a StyleGuide with a custom parser.
1373
1374 · Accept visual indentation without parenthesis after the if statement.
1375 (Issue #151)
1376
1377 · Fix UnboundLocalError when using # noqa with continued lines. (Issue
1378 #158)
1379
1380 · Re-order the lines for the StandardReport.
1381
1382 · Expand tabs when checking E12 continuation lines. (Issue #155)
1383
1384 · Refactor the testing class TestReport and the specific test functions
1385 into a separate test module.
1386
1387 1.4.1 (2013-01-18)
1388 · Allow sphinx.ext.autodoc syntax for comments. (Issue #110)
1389
1390 · Report E703 instead of E702 for the trailing semicolon. (Issue #117)
1391
1392 · Honor # noqa in addition to # nopep8. (Issue #149)
1393
1394 · Expose the OptionParser factory for better extensibility.
1395
1396 1.4 (2012-12-22)
1397 · Report E226 instead of E225 for optional whitespace around common
1398 operators (*, **, /, + and -). This new error code is ignored in the
1399 default configuration because PEP 8 recommends to "use your own
1400 judgement". (Issue #96)
1401
1402 · Lines with a # nopep8 at the end will not issue errors on line length
1403 E501 or continuation line indentation E12*. (Issue #27)
1404
1405 · Fix AssertionError when the source file contains an invalid line end‐
1406 ing "\r\r\n". (Issue #119)
1407
1408 · Read the [pep8] section of tox.ini or setup.cfg if present. (Issue
1409 #93 and #141)
1410
1411 · Add the Sphinx-based documentation, and publish it on
1412 https://pycodestyle.readthedocs.io/. (Issue #105)
1413
1414 1.3.4 (2012-12-18)
1415 · Fix false positive E124 and E128 with comments. (Issue #100)
1416
1417 · Fix error on stdin when running with bpython. (Issue #101)
1418
1419 · Fix false positive E401. (Issue #104)
1420
1421 · Report E231 for nested dictionary in list. (Issue #142)
1422
1423 · Catch E271 at the beginning of the line. (Issue #133)
1424
1425 · Fix false positive E126 for multi-line comments. (Issue #138)
1426
1427 · Fix false positive E221 when operator is preceded by a comma. (Issue
1428 #135)
1429
1430 · Fix --diff failing on one-line hunk. (Issue #137)
1431
1432 · Fix the --exclude switch for directory paths. (Issue #111)
1433
1434 · Use - filename to read from standard input. (Issue #128)
1435
1436 1.3.3 (2012-06-27)
1437 · Fix regression with continuation line checker. (Issue #98)
1438
1439 1.3.2 (2012-06-26)
1440 · Revert to the previous behaviour for --show-pep8: do not imply
1441 --first. (Issue #89)
1442
1443 · Add E902 for IO errors. (Issue #87)
1444
1445 · Fix false positive for E121, and missed E124. (Issue #92)
1446
1447 · Set a sensible default path for config file on Windows. (Issue #95)
1448
1449 · Allow verbose in the configuration file. (Issue #91)
1450
1451 · Show the enforced max-line-length in the error message. (Issue #86)
1452
1453 1.3.1 (2012-06-18)
1454 · Explain which configuration options are expected. Accept and recom‐
1455 mend the options names with hyphen instead of underscore. (Issue #82)
1456
1457 · Do not read the user configuration when used as a module (except if
1458 config_file=True is passed to the StyleGuide constructor).
1459
1460 · Fix wrong or missing cases for the E12 series.
1461
1462 · Fix cases where E122 was missed. (Issue #81)
1463
1464 1.3 (2012-06-15)
1465 WARNING:
1466 The internal API is backwards incompatible.
1467
1468 · Remove global configuration and refactor the library around a
1469 StyleGuide class; add the ability to configure various reporters.
1470 (Issue #35 and #66)
1471
1472 · Read user configuration from ~/.config/pep8 and local configuration
1473 from ./.pep8. (Issue #22)
1474
1475 · Fix E502 for backslash embedded in multi-line string. (Issue #68)
1476
1477 · Fix E225 for Python 3 iterable unpacking (PEP 3132). (Issue #72)
1478
1479 · Enable the new checkers from the E12 series in the default configura‐
1480 tion.
1481
1482 · Suggest less error-prone alternatives for E712 errors.
1483
1484 · Rewrite checkers to run faster (E22, E251, E27).
1485
1486 · Fixed a crash when parsed code is invalid (too many closing brack‐
1487 ets).
1488
1489 · Fix E127 and E128 for continuation line indentation. (Issue #74)
1490
1491 · New option --format to customize the error format. (Issue #23)
1492
1493 · New option --diff to check only modified code. The unified diff is
1494 read from STDIN. Example: hg diff | pep8 --diff (Issue #39)
1495
1496 · Correctly report the count of failures and set the exit code to 1
1497 when the --doctest or the --testsuite fails.
1498
1499 · Correctly detect the encoding in Python 3. (Issue #69)
1500
1501 · Drop support for Python 2.3, 2.4 and 3.0. (Issue #78)
1502
1503 1.2 (2012-06-01)
1504 · Add E121 through E128 for continuation line indentation. These
1505 checks are disabled by default. If you want to force all checks, use
1506 switch --select=E,W. Patch by Sam Vilain. (Issue #64)
1507
1508 · Add E721 for direct type comparisons. (Issue #47)
1509
1510 · Add E711 and E712 for comparisons to singletons. (Issue #46)
1511
1512 · Fix spurious E225 and E701 for function annotations. (Issue #29)
1513
1514 · Add E502 for explicit line join between brackets.
1515
1516 · Fix E901 when printing source with --show-source.
1517
1518 · Report all errors for each checker, instead of reporting only the
1519 first occurrence for each line.
1520
1521 · Option --show-pep8 implies --first.
1522
1523 1.1 (2012-05-24)
1524 · Add E901 for syntax errors. (Issues #63 and #30)
1525
1526 · Add E271, E272, E273 and E274 for extraneous whitespace around key‐
1527 words. (Issue #57)
1528
1529 · Add tox.ini configuration file for tests. (Issue #61)
1530
1531 · Add .travis.yml configuration file for continuous integration.
1532 (Issue #62)
1533
1534 1.0.1 (2012-04-06)
1535 · Fix inconsistent version numbers.
1536
1537 1.0 (2012-04-04)
1538 · Fix W602 raise to handle multi-char names. (Issue #53)
1539
1540 0.7.0 (2012-03-26)
1541 · Now --first prints only the first occurrence of each error. The
1542 --repeat flag becomes obsolete because it is the default behaviour.
1543 (Issue #6)
1544
1545 · Allow specifying --max-line-length. (Issue #36)
1546
1547 · Make the shebang more flexible. (Issue #26)
1548
1549 · Add testsuite to the bundle. (Issue #25)
1550
1551 · Fixes for Jython. (Issue #49)
1552
1553 · Add PyPI classifiers. (Issue #43)
1554
1555 · Fix the --exclude option. (Issue #48)
1556
1557 · Fix W602, accept raise with 3 arguments. (Issue #34)
1558
1559 · Correctly select all tests if DEFAULT_IGNORE == ''.
1560
1561 0.6.1 (2010-10-03)
1562 · Fix inconsistent version numbers. (Issue #21)
1563
1564 0.6.0 (2010-09-19)
1565 · Test suite reorganized and enhanced in order to check more failures
1566 with fewer test files. Read the run_tests docstring for details
1567 about the syntax.
1568
1569 · Fix E225: accept print >>sys.stderr, "..." syntax.
1570
1571 · Fix E501 for lines containing multibyte encoded characters. (Issue
1572 #7)
1573
1574 · Fix E221, E222, E223, E224 not detected in some cases. (Issue #16)
1575
1576 · Fix E211 to reject v = dic['a'] ['b']. (Issue #17)
1577
1578 · Exit code is always 1 if any error or warning is found. (Issue #10)
1579
1580 · --ignore checks are now really ignored, especially in conjunction
1581 with --count. (Issue #8)
1582
1583 · Blank lines with spaces yield W293 instead of W291: some developers
1584 want to ignore this warning and indent the blank lines to paste their
1585 code easily in the Python interpreter.
1586
1587 · Fix E301: do not require a blank line before an indented block.
1588 (Issue #14)
1589
1590 · Fix E203 to accept NumPy slice notation a[0, :]. (Issue #13)
1591
1592 · Performance improvements.
1593
1594 · Fix decoding and checking non-UTF8 files in Python 3.
1595
1596 · Fix E225: reject True+False when running on Python 3.
1597
1598 · Fix an exception when the line starts with an operator.
1599
1600 · Allow a new line before closing ), } or ]. (Issue #5)
1601
1602 0.5.0 (2010-02-17)
1603 · Changed the --count switch to print to sys.stderr and set exit code
1604 to 1 if any error or warning is found.
1605
1606 · E241 and E242 are removed from the standard checks. If you want to
1607 include these checks, use switch --select=E,W. (Issue #4)
1608
1609 · Blank line is not mandatory before the first class method or nested
1610 function definition, even if there's a docstring. (Issue #1)
1611
1612 · Add the switch --version.
1613
1614 · Fix decoding errors with Python 3. (Issue #13 [1])
1615
1616 · Add --select option which is mirror of --ignore.
1617
1618 · Add checks E261 and E262 for spaces before inline comments.
1619
1620 · New check W604 warns about deprecated usage of backticks.
1621
1622 · New check W603 warns about the deprecated operator <>.
1623
1624 · Performance improvement, due to rewriting of E225.
1625
1626 · E225 now accepts:
1627
1628 · no whitespace after unary operator or similar. (Issue #9 [1])
1629
1630 · lambda function with argument unpacking or keyword defaults.
1631
1632 · Reserve "2 blank lines" for module-level logical blocks. (E303)
1633
1634 · Allow multi-line comments. (E302, issue #10 [1])
1635
1636 0.4.2 (2009-10-22)
1637 · Decorators on classes and class methods are OK now.
1638
1639 0.4 (2009-10-20)
1640 · Support for all versions of Python from 2.3 to 3.1.
1641
1642 · New and greatly expanded self tests.
1643
1644 · Added --count option to print the total number of errors and warn‐
1645 ings.
1646
1647 · Further improvements to the handling of comments and blank lines.
1648 (Issue #1 [1] and others changes.)
1649
1650 · Check all py files in directory when passed a directory (Issue #2
1651 [1]). This also prevents an exception when traversing directories
1652 with non *.py files.
1653
1654 · E231 should allow commas to be followed by ). (Issue #3 [1])
1655
1656 · Spaces are no longer required around the equals sign for keyword
1657 arguments or default parameter values.
1658
1659 [1] These issues refer to the previous issue tracker.
1660
1661 0.3.1 (2009-09-14)
1662 · Fixes for comments: do not count them when checking for blank lines
1663 between items.
1664
1665 · Added setup.py for pypi upload and easy_installability.
1666
1667 0.2 (2007-10-16)
1668 · Loads of fixes and improvements.
1669
1670 0.1 (2006-10-01)
1671 · First release.
1672
1673 · Online documentation: https://pycodestyle.readthedocs.io/
1674
1675 · Source code and issue tracker: https://github.com/pycqa/pycodestyle
1676
1677 · genindex
1678
1679 · search
1680
1681 Created by Johann C. Rocholl.
1682
1683 Maintained by Florent Xicluna and Ian Lee.
1684
1685 The pycodestyle library is provided under the terms and conditions of
1686 the Expat license:
1687
1688 # Permission is hereby granted, free of charge, to any person
1689 # obtaining a copy of this software and associated documentation files
1690 # (the "Software"), to deal in the Software without restriction,
1691 # including without limitation the rights to use, copy, modify, merge,
1692 # publish, distribute, sublicense, and/or sell copies of the Software,
1693 # and to permit persons to whom the Software is furnished to do so,
1694 # subject to the following conditions:
1695 #
1696 # The above copyright notice and this permission notice shall be
1697 # included in all copies or substantial portions of the Software.
1698 #
1699 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1700 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1701 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1702 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1703 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1704 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1705 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1706 # SOFTWARE.
1707
1709 Johann C. Rocholl, Florent Xicluna, Ian Lee
1710
1712 2006-2016, Johann C. Rocholl, Florent Xicluna, Ian Lee
1713
1714
1715
1716
17172.4 Jul 15, 2018 PYCODESTYLE(1)