1pylint(1) General Commands Manual pylint(1)
2
3
4
6 pylint - python code static checker
7
8
10 pylint [ OPTIONS ] [ <arguments> ]
11
12
14 pylint is a Python source code analyzer which looks for programming
15 errors, helps enforcing a coding standard and sniffs for some code
16 smells (as defined in Martin Fowler's Refactoring book)
17
18 Pylint can be seen as another PyChecker since nearly all tests you can
19 do with PyChecker can also be done with Pylint. However, Pylint offers
20 some more features, like checking length of lines of code, checking if
21 variable names are well-formed according to your coding standard, or
22 checking if declared interfaces are truly implemented, and much more.
23
24 Additionally, it is possible to write plugins to add your own checks.
25
26 Pylint is shipped with "pylint-gui", "pyreverse" (UML diagram genera‐
27 tor) and "symilar" (an independent similarities checker).
28
29
31 --version
32 show program's version number and exit
33
34 --help, -h
35 show this help message and exit
36
37 --long-help
38 more verbose help.
39
40
42 --rcfile=<file>
43 Specify a configuration file.
44
45 --init-hook=<code>
46 Python code to execute, usually for sys.path manipulation such
47 as pygtk.require().
48
49 --errors-only, -E
50 In error mode, checkers without error messages are disabled and
51 for others, only the ERROR messages are displayed, and no
52 reports are done by default
53
54 --py3k In Python 3 porting mode, all checkers will be disabled and only
55 messages emitted by the porting checker will be displayed
56
57 --ignore=<file>[,<file>...]
58 Add files or directories to the blacklist. They should be base
59 names, not paths. [current: CVS]
60
61 --persistent=<y_or_n>
62 Pickle collected data for later comparisons. [current: yes]
63
64 --load-plugins=<modules>
65 List of plugins (as comma separated values of python modules
66 names) to load, usually to register additional checkers. [cur‐
67 rent: none]
68
69 --jobs=<n-processes>, -j <n-processes>
70 Use multiple processes to speed up Pylint. [current: 1]
71
72 --extension-pkg-whitelist=<pkg[,pkg]>
73 A comma-separated list of package or module names from where C
74 extensions may be loaded. Extensions are loading into the active
75 Python interpreter and may run arbitrary code [current: none]
76
77
79 --help-msg=<msg-id>
80 Display a help message for the given message id and exit. The
81 value may be a comma separated list of message ids.
82
83 --list-msgs
84 Generate pylint's messages.
85
86 --list-conf-levels
87 Generate pylint's messages.
88
89 --full-documentation
90 Generate pylint's full documentation.
91
92 --generate-rcfile
93 Generate a sample configuration file according to the current
94 configuration. You can put other options before this one to get
95 them in the generated configuration.
96
97
99 --confidence=<levels>
100 Only show warnings with the listed confidence levels. Leave
101 empty to show all. Valid levels: HIGH, INFERENCE, INFER‐
102 ENCE_FAILURE, UNDEFINED [current: none]
103
104 --enable=<msg ids>, -e <msg ids>
105 Enable the message, report, category or checker with the given
106 id(s). You can either give multiple identifier separated by
107 comma (,) or put this option multiple time. See also the "--dis‐
108 able" option for examples.
109
110 --disable=<msg ids>, -d <msg ids>
111 Disable the message, report, category or checker with the given
112 id(s). You can either give multiple identifiers separated by
113 comma (,) or put this option multiple times (only on the command
114 line, not in the configuration file where it should appear only
115 once).You can also use "--disable=all" to disable everything
116 first and then reenable specific checks. For example, if you
117 want to run only the similarities checker, you can use "--dis‐
118 able=all --enable=similarities". If you want to run only the
119 classes checker, but have no Warning level messages displayed,
120 use"--disable=all --enable=classes --disable=W"
121
122
124 --output-format=<format>, -f <format>
125 Set the output format. Available formats are text, parseable,
126 colorized, msvs (visual studio) and html. You can also give a
127 reporter class, eg mypackage.mymodule.MyReporterClass. [current:
128 text]
129
130 --files-output=<y_or_n>
131 Put messages in a separate file for each module / package speci‐
132 fied on the command line instead of printing them on stdout.
133 Reports (if any) will be written in a file name
134 "pylint_global.[txt|html]". [current: no]
135
136 --reports=<y_or_n>, -r <y_or_n>
137 Tells whether to display a full report or only the messages
138 [current: yes]
139
140 --evaluation=<python_expression>
141 Python expression which should return a note less than 10 (10 is
142 the highest note). You have access to the variables errors warn‐
143 ing, statement which respectively contain the number of errors /
144 warnings messages and the total number of statements analyzed.
145 This is used by the global evaluation report (RP0004). [current:
146 10.0 - ((float(5 * error + warning + refactor + convention) /
147 statement) * 10)]
148
149 --comment=<y_or_n>
150 Add a comment according to your evaluation note. This is used by
151 the global evaluation report (RP0004). [current: no]
152
153 --msg-template=<template>
154 Template used to display messages. This is a python new-style
155 format string used to format the message information. See doc
156 for all details
157
158
160 --overgeneral-exceptions=<comma-separated class names>
161 Exceptions that will emit a warning when being caught. Defaults
162 to "Exception" [current: Exception]
163
164
166 --ignore-iface-methods=<method names>
167 List of interface methods to ignore, separated by a comma. This
168 is used for instance to not check methods defines in Zope's
169 Interface base class. [current: isImplement‐
170 edBy,deferred,extends,names,namesAndDescriptions,queryDescrip‐
171 tionFor,getBases,getDescriptionFor,getDoc,getName,getTagged‐
172 Value,getTaggedValueTags,isEqualOrExtendedBy,setTagged‐
173 Value,isImplementedByInstancesOf,adaptWith,is_implemented_by]
174
175 --defining-attr-methods=<method names>
176 List of method names used to declare (i.e. assign) instance
177 attributes. [current: __init__,__new__,setUp]
178
179 --valid-classmethod-first-arg=<argument names>
180 List of valid names for the first argument in a class method.
181 [current: cls]
182
183 --valid-metaclass-classmethod-first-arg=<argument names>
184 List of valid names for the first argument in a metaclass class
185 method. [current: mcs]
186
187 --exclude-protected=<protected access exclusions>
188 List of member names, which should be excluded from the pro‐
189 tected access warning. [current:
190 _asdict,_fields,_replace,_source,_make]
191
192
194 --logging-modules=<comma separated list>
195 Logging modules to check that the string format arguments are in
196 logging function parameter format [current: logging]
197
198
200 --init-import=<y_or_n>
201 Tells whether we should check for unused import in __init__
202 files. [current: no]
203
204 --dummy-variables-rgx=<regexp>
205 A regular expression matching the name of dummy variables (i.e.
206 expectedly not used). [current: _$|dummy]
207
208 --additional-builtins=<comma separated list>
209 List of additional names supposed to be defined in builtins.
210 Remember that you should avoid to define new builtins when pos‐
211 sible. [current: none]
212
213 --callbacks=<callbacks>
214 List of strings which can identify a callback function by name.
215 A callback name must start or end with one of those strings.
216 [current: cb_,_cb]
217
218
220 --max-args=<int>
221 Maximum number of arguments for function / method [current: 5]
222
223 --ignored-argument-names=<regexp>
224 Argument names that match this expression will be ignored.
225 Default to name with leading underscore [current: _.*]
226
227 --max-locals=<int>
228 Maximum number of locals for function / method body [current:
229 15]
230
231 --max-returns=<int>
232 Maximum number of return / yield for function / method body
233 [current: 6]
234
235 --max-branches=<int>
236 Maximum number of branch for function / method body [current:
237 12]
238
239 --max-statements=<int>
240 Maximum number of statements in function / method body [current:
241 50]
242
243 --max-parents=<num>
244 Maximum number of parents for a class (see R0901). [current: 7]
245
246 --max-attributes=<num>
247 Maximum number of attributes for a class (see R0902). [current:
248 7]
249
250 --min-public-methods=<num>
251 Minimum number of public methods for a class (see R0903). [cur‐
252 rent: 2]
253
254 --max-public-methods=<num>
255 Maximum number of public methods for a class (see R0904). [cur‐
256 rent: 20]
257
258
260 --required-attributes=<attributes>
261 Required attributes for module, separated by a comma [current:
262 none]
263
264 --bad-functions=<builtin function names>
265 List of builtins function names that should not be used, sepa‐
266 rated by a comma [current: map,filter,input]
267
268 --good-names=<names>
269 Good variable names which should always be accepted, separated
270 by a comma [current: i,j,k,ex,Run,_]
271
272 --bad-names=<names>
273 Bad variable names which should always be refused, separated by
274 a comma [current: foo,bar,baz,toto,tutu,tata]
275
276 --name-group=<name1:name2>
277 Colon-delimited sets of names that determine each other's naming
278 style when the name regexes allow several styles. [current:
279 none]
280
281 --include-naming-hint=<y_or_n>
282 Include a hint for the correct naming format with invalid-name
283 [current: no]
284
285 --function-rgx=<regexp>
286 Regular expression matching correct function names [current: [a-
287 z_][a-z0-9_]{2,30}$]
288
289 --function-name-hint=<string>
290 Naming hint for function names [current: [a-z_][a-z0-9_]{2,30}$]
291
292 --variable-rgx=<regexp>
293 Regular expression matching correct variable names [current: [a-
294 z_][a-z0-9_]{2,30}$]
295
296 --variable-name-hint=<string>
297 Naming hint for variable names [current: [a-z_][a-z0-9_]{2,30}$]
298
299 --const-rgx=<regexp>
300 Regular expression matching correct constant names [current:
301 (([A-Z_][A-Z0-9_]*)|(__.*__))$]
302
303 --const-name-hint=<string>
304 Naming hint for constant names [current: (([A-Z_][A-
305 Z0-9_]*)|(__.*__))$]
306
307 --attr-rgx=<regexp>
308 Regular expression matching correct attribute names [current:
309 [a-z_][a-z0-9_]{2,30}$]
310
311 --attr-name-hint=<string>
312 Naming hint for attribute names [current: [a-z_][a-
313 z0-9_]{2,30}$]
314
315 --argument-rgx=<regexp>
316 Regular expression matching correct argument names [current: [a-
317 z_][a-z0-9_]{2,30}$]
318
319 --argument-name-hint=<string>
320 Naming hint for argument names [current: [a-z_][a-z0-9_]{2,30}$]
321
322 --class-attribute-rgx=<regexp>
323 Regular expression matching correct class attribute names [cur‐
324 rent: ([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$]
325
326 --class-attribute-name-hint=<string>
327 Naming hint for class attribute names [current: ([A-Za-z_][A-Za-
328 z0-9_]{2,30}|(__.*__))$]
329
330 --inlinevar-rgx=<regexp>
331 Regular expression matching correct inline iteration names [cur‐
332 rent: [A-Za-z_][A-Za-z0-9_]*$]
333
334 --inlinevar-name-hint=<string>
335 Naming hint for inline iteration names [current: [A-Za-z_][A-Za-
336 z0-9_]*$]
337
338 --class-rgx=<regexp>
339 Regular expression matching correct class names [current: [A-
340 Z_][a-zA-Z0-9]+$]
341
342 --class-name-hint=<string>
343 Naming hint for class names [current: [A-Z_][a-zA-Z0-9]+$]
344
345 --module-rgx=<regexp>
346 Regular expression matching correct module names [current: (([a-
347 z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$]
348
349 --module-name-hint=<string>
350 Naming hint for module names [current: (([a-z_][a-z0-9_]*)|([A-
351 Z][a-zA-Z0-9]+))$]
352
353 --method-rgx=<regexp>
354 Regular expression matching correct method names [current: [a-
355 z_][a-z0-9_]{2,30}$]
356
357 --method-name-hint=<string>
358 Naming hint for method names [current: [a-z_][a-z0-9_]{2,30}$]
359
360 --no-docstring-rgx=<regexp>
361 Regular expression which should only match function or class
362 names that do not require a docstring. [current: __.*__]
363
364 --docstring-min-length=<int>
365 Minimum line length for functions/classes that require doc‐
366 strings, shorter ones are exempt. [current: -1]
367
368
370 --notes=<comma separated values>
371 List of note tags to take in consideration, separated by a
372 comma. [current: FIXME,XXX,TODO]
373
374
376 --ignore-mixin-members=<y_or_n>
377 Tells whether missing members accessed in mixin class should be
378 ignored. A mixin class is detected if its name ends with "mixin"
379 (case insensitive). [current: yes]
380
381 --ignored-modules=<module names>
382 List of module names for which member attributes should not be
383 checked (useful for modules/projects where namespaces are manip‐
384 ulated during runtime and thus existing member attributes cannot
385 be deduced by static analysis [current: none]
386
387 --ignored-classes=<members names>
388 List of classes names for which member attributes should not be
389 checked (useful for classes with attributes dynamically set).
390 [current: SQLObject, optparse.Values, thread._local,
391 _thread._local]
392
393 --zope=<y_or_n>
394 When zope mode is activated, add a predefined set of Zope
395 acquired attributes to generated-members. [current: no]
396
397 --generated-members=<members names>
398 List of members which are set dynamically and missed by pylint
399 inference system, and so shouldn't trigger E1101 when accessed.
400 Python regular expressions are accepted. [current:
401 REQUEST,acl_users,aq_parent]
402
403
405 --spelling-dict=<dict name>
406 Spelling dictionary name. Available dictionaries: none. To make
407 it working install python-enchant package. [current: none]
408
409 --spelling-ignore-words=<comma separated words>
410 List of comma separated words that should not be checked. [cur‐
411 rent: none]
412
413 --spelling-private-dict-file=<path to file>
414 A path to a file that contains private dictionary; one word per
415 line. [current: none]
416
417 --spelling-store-unknown-words=<y_or_n>
418 Tells whether to store unknown words to indicated private dic‐
419 tionary in --spelling-private-dict-file option instead of rais‐
420 ing a message. [current: no]
421
422
424 --max-line-length=<int>
425 Maximum number of characters on a single line. [current: 100]
426
427 --ignore-long-lines=<regexp>
428 Regexp for a line that is allowed to be longer than the limit.
429 [current: ^(# )?<?https?://>?$]
430
431 --single-line-if-stmt=<y_or_n>
432 Allow the body of an if to be on the same line as the test if
433 there is no else. [current: no]
434
435 --no-space-check=NO_SPACE_CHECK
436 List of optional constructs for which whitespace checking is
437 disabled [current: trailing-comma,dict-separator]
438
439 --max-module-lines=<int>
440 Maximum number of lines in a module [current: 1000]
441
442 --indent-string=<string>
443 String used as indentation unit. This is usually " " (4 spa‐
444 ces) or "\t" (1 tab). [current: ' ']
445
446 --indent-after-paren=<int>
447 Number of spaces of indent required inside a hanging or contin‐
448 ued line. [current: 4]
449
450 --expected-line-ending-format=<empty or LF or CRLF>
451 Expected format of line ending, e.g. empty (any line ending), LF
452 or CRLF. [current: none]
453
454
456 --deprecated-modules=<modules>
457 Deprecated modules which should not be used, separated by a
458 comma [current: regsub,TERMIOS,Bastion,rexec]
459
460 --import-graph=<file.dot>
461 Create a graph of every (i.e. internal and external) dependen‐
462 cies in the given file (report RP0402 must not be disabled)
463 [current: none]
464
465 --ext-import-graph=<file.dot>
466 Create a graph of external dependencies in the given file
467 (report RP0402 must not be disabled) [current: none]
468
469 --int-import-graph=<file.dot>
470 Create a graph of internal dependencies in the given file
471 (report RP0402 must not be disabled) [current: none]
472
473
475 --min-similarity-lines=<int>
476 Minimum lines number of a similarity. [current: 4]
477
478 --ignore-comments=<y or n>
479 Ignore comments when computing similarities. [current: yes]
480
481 --ignore-docstrings=<y or n>
482 Ignore docstrings when computing similarities. [current: yes]
483
484 --ignore-imports=<y or n>
485 Ignore imports when computing similarities. [current: no]
486
487
489 The following environment variables are used:
490 * PYLINTHOME
491 Path to the directory where the persistent for the run will be
492 stored. If not found, it defaults to ~/.pylint.d/ or .pylint.d (in the
493 current working directory).
494 * PYLINTRC
495 Path to the configuration file. See the documentation for the
496 method used to search for configuration file.
497
498
500 Using the default text output, the message format is :
501
502 MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
503
504 There are 5 kind of message types :
505 * (C) convention, for programming standard violation
506 * (R) refactor, for bad code smell
507 * (W) warning, for python specific problems
508 * (E) error, for probable bugs in the code
509 * (F) fatal, if an error occurred which prevented pylint from doing
510 further processing.
511
512
514 Pylint should leave with following status code:
515 * 0 if everything went fine
516 * 1 if a fatal message was issued
517 * 2 if an error message was issued
518 * 4 if a warning message was issued
519 * 8 if a refactor message was issued
520 * 16 if a convention message was issued
521 * 32 on usage error
522
523 status 1 to 16 will be bit-ORed so you can know which different cate‐
524 gories has been issued by analysing pylint output status code
525
526
528 /usr/share/doc/pythonX.Y-pylint/
529
530
532 Please report bugs on the project's mailing list: mailto:code-qual‐
533 ity@python.org
534
535
537 Logilab <python-projects@lists.logilab.org>
538
539
540
541
542pylint 2015-2-27 pylint(1)