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 "pyreverse" (UML diagram generator) and "symi‐
27 lar" (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 --verbose, -v
58 In verbose mode, extra non-checker-related info will be dis‐
59 played.
60
61 --ignore=<file>[,<file>...]
62 Add files or directories to the blacklist. They should be base
63 names, not paths. [default: CVS]
64
65 --ignore-patterns=<pattern>[,<pattern>...]
66 Add files or directories matching the regex patterns to the
67 blacklist. The regex matches against base names, not paths.
68 [default: none]
69
70 --persistent=<y_or_n>
71 Pickle collected data for later comparisons. [default: yes]
72
73 --load-plugins=<modules>
74 List of plugins (as comma separated values of python module
75 names) to load, usually to register additional checkers.
76 [default: none]
77
78 --jobs=<n-processes>, -j <n-processes>
79 Use multiple processes to speed up Pylint. Specifying 0 will
80 auto-detect the number of processors available to use. [default:
81 1]
82
83 --limit-inference-results=<number-of-results>
84 Control the amount of potential inferred values when inferring a
85 single object. This can help the performance when dealing with
86 large functions or complex, nested conditions. [default: 100]
87
88 --extension-pkg-whitelist=<pkg[,pkg]>
89 A comma-separated list of package or module names from where C
90 extensions may be loaded. Extensions are loading into the active
91 Python interpreter and may run arbitrary code. [default: none]
92
93 --suggestion-mode=<yn>
94 When enabled, pylint would attempt to guess common misconfigura‐
95 tion and emit user-friendly hints instead of false-positive
96 error messages. [default: yes]
97
98 --exit-zero
99 Always return a 0 (non-error) status code, even if lint errors
100 are found. This is primarily useful in continuous integration
101 scripts.
102
103 --from-stdin
104 Interpret the stdin as a python script, whose filename needs to
105 be passed as the module_or_package argument.
106
107
109 --help-msg=<msg-id>
110 Display a help message for the given message id and exit. The
111 value may be a comma separated list of message ids.
112
113 --list-msgs
114 Generate pylint's messages.
115
116 --list-groups
117 List pylint's message groups.
118
119 --list-conf-levels
120 Generate pylint's confidence levels.
121
122 --full-documentation
123 Generate pylint's full documentation.
124
125 --generate-rcfile
126 Generate a sample configuration file according to the current
127 configuration. You can put other options before this one to get
128 them in the generated configuration.
129
130
132 --confidence=<levels>
133 Only show warnings with the listed confidence levels. Leave
134 empty to show all. Valid levels: HIGH, INFERENCE, INFER‐
135 ENCE_FAILURE, UNDEFINED. [default: none]
136
137 --enable=<msg ids>, -e <msg ids>
138 Enable the message, report, category or checker with the given
139 id(s). You can either give multiple identifier separated by
140 comma (,) or put this option multiple time (only on the command
141 line, not in the configuration file where it should appear only
142 once). See also the "--disable" option for examples.
143
144 --disable=<msg ids>, -d <msg ids>
145 Disable the message, report, category or checker with the given
146 id(s). You can either give multiple identifiers separated by
147 comma (,) or put this option multiple times (only on the command
148 line, not in the configuration file where it should appear only
149 once). You can also use "--disable=all" to disable everything
150 first and then reenable specific checks. For example, if you
151 want to run only the similarities checker, you can use "--dis‐
152 able=all --enable=similarities". If you want to run only the
153 classes checker, but have no Warning level messages displayed,
154 use "--disable=all --enable=classes --disable=W".
155
156
158 --output-format=<format>, -f <format>
159 Set the output format. Available formats are text, parseable,
160 colorized, json and msvs (visual studio). You can also give a
161 reporter class, e.g. mypackage.mymodule.MyReporterClass.
162 [default: text]
163
164 --reports=<y_or_n>, -r <y_or_n>
165 Tells whether to display a full report or only the messages.
166 [default: no]
167
168 --evaluation=<python_expression>
169 Python expression which should return a score less than or equal
170 to 10. You have access to the variables 'error', 'warning',
171 'refactor', and 'convention' which contain the number of mes‐
172 sages in each category, as well as 'statement' which is the
173 total number of statements analyzed. This score is used by the
174 global evaluation report (RP0004). [default: 10.0 - ((float(5 *
175 error + warning + refactor + convention) / statement) * 10)]
176
177 --score=<y_or_n>, -s <y_or_n>
178 Activate the evaluation score. [default: yes]
179
180 --msg-template=<template>
181 Template used to display messages. This is a python new-style
182 format string used to format the message information. See doc
183 for all details.
184
185
187 --ignore-on-opaque-inference=<y_or_n>
188 This flag controls whether pylint should warn about no-member
189 and similar checks whenever an opaque object is returned when
190 inferring. The inference can return multiple potential results
191 while evaluating a Python object, but some branches might not be
192 evaluated, which results in partial inference. In that case, it
193 might be useful to still emit no-member and other checks for the
194 rest of the inferred objects. [default: yes]
195
196 --ignore-mixin-members=<y_or_n>
197 Tells whether missing members accessed in mixin class should be
198 ignored. A mixin class is detected if its name ends with "mixin"
199 (case insensitive). [default: yes]
200
201 --ignore-none=<y_or_n>
202 Tells whether to warn about missing members when the owner of
203 the attribute is inferred to be None. [default: yes]
204
205 --ignored-modules=<module names>
206 List of module names for which member attributes should not be
207 checked (useful for modules/projects where namespaces are manip‐
208 ulated during runtime and thus existing member attributes cannot
209 be deduced by static analysis). It supports qualified module
210 names, as well as Unix pattern matching. [default: none]
211
212 --ignored-classes=<members names>
213 List of class names for which member attributes should not be
214 checked (useful for classes with dynamically set attributes).
215 This supports the use of qualified names. [default: opt‐
216 parse.Values,thread._local,_thread._local]
217
218 --generated-members=<members names>
219 List of members which are set dynamically and missed by pylint
220 inference system, and so shouldn't trigger E1101 when accessed.
221 Python regular expressions are accepted. [default: none]
222
223 --contextmanager-decorators=<decorator names>
224 List of decorators that produce context managers, such as con‐
225 textlib.contextmanager. Add to this list to register other deco‐
226 rators that produce valid context managers. [default: con‐
227 textlib.contextmanager]
228
229 --missing-member-hint-distance=<member hint edit distance>
230 The minimum edit distance a name should have in order to be con‐
231 sidered a similar match for a missing member name. [default: 1]
232
233 --missing-member-max-choices=<member hint max choices>
234 The total number of similar names that should be taken in con‐
235 sideration when showing a hint for a missing member. [default:
236 1]
237
238 --missing-member-hint=<missing member hint>
239 Show a hint with possible names when a member name was not
240 found. The aspect of finding the hint is based on edit distance.
241 [default: yes]
242
243 --signature-mutators=<decorator names>
244 List of decorators that change the signature of a decorated
245 function. [default: none]
246
247
249 --logging-modules=<comma separated list>
250 Logging modules to check that the string format arguments are in
251 logging function parameter format. [default: logging]
252
253 --logging-format-style=<old (%) or new ({)>
254 Format style used to check logging format string. `old` means
255 using % formatting, while `new` is for `{}` formatting.
256 [default: old]
257
258
260 --overgeneral-exceptions=<comma-separated class names>
261 Exceptions that will emit a warning when being caught. Defaults
262 to "BaseException, Exception". [default: BaseException,Excep‐
263 tion]
264
265
267 --min-similarity-lines=<int>
268 Minimum lines number of a similarity. [default: 4]
269
270 --ignore-comments=<y or n>
271 Ignore comments when computing similarities. [default: yes]
272
273 --ignore-docstrings=<y or n>
274 Ignore docstrings when computing similarities. [default: yes]
275
276 --ignore-imports=<y or n>
277 Ignore imports when computing similarities. [default: no]
278
279
281 --deprecated-modules=<modules>
282 Deprecated modules which should not be used, separated by a
283 comma. [default: optparse,tkinter.tix]
284
285 --preferred-modules=<module:preferred-module>
286 Couples of modules and preferred modules, separated by a comma.
287 [default: none]
288
289 --import-graph=<file.dot>
290 Create a graph of every (i.e. internal and external) dependen‐
291 cies in the given file (report RP0402 must not be disabled).
292 [default: none]
293
294 --ext-import-graph=<file.dot>
295 Create a graph of external dependencies in the given file
296 (report RP0402 must not be disabled). [default: none]
297
298 --int-import-graph=<file.dot>
299 Create a graph of internal dependencies in the given file
300 (report RP0402 must not be disabled). [default: none]
301
302 --known-standard-library=<modules>
303 Force import order to recognize a module as part of the standard
304 compatibility libraries. [default: none]
305
306 --known-third-party=<modules>
307 Force import order to recognize a module as part of a third
308 party library. [default: enchant]
309
310 --analyse-fallback-blocks=<y_or_n>
311 Analyse import fallback blocks. This can be used to support both
312 Python 2 and 3 compatible code, which means that the block might
313 have code that exists only in one or another interpreter, lead‐
314 ing to false positives when analysed. [default: no]
315
316 --allow-wildcard-with-all=<y_or_n>
317 Allow wildcard imports from modules that define __all__.
318 [default: no]
319
320
322 --init-import=<y_or_n>
323 Tells whether we should check for unused import in __init__
324 files. [default: no]
325
326 --dummy-variables-rgx=<regexp>
327 A regular expression matching the name of dummy variables (i.e.
328 expected to not be used). [default: _+$|(_[a-zA-Z0-9_]*[a-zA-
329 Z0-9]+?$)|dummy|^ignored_|^unused_]
330
331 --additional-builtins=<comma separated list>
332 List of additional names supposed to be defined in builtins.
333 Remember that you should avoid defining new builtins when possi‐
334 ble. [default: none]
335
336 --callbacks=<callbacks>
337 List of strings which can identify a callback function by name.
338 A callback name must start or end with one of those strings.
339 [default: cb_,_cb]
340
341 --redefining-builtins-modules=<comma separated list>
342 List of qualified module names which can have objects that can
343 redefine builtins. [default:
344 six.moves,past.builtins,future.builtins,builtins,io]
345
346 --ignored-argument-names=<regexp>
347 Argument names that match this expression will be ignored.
348 Default to name with leading underscore. [default:
349 _.*|^ignored_|^unused_]
350
351 --allow-global-unused-variables=<y_or_n>
352 Tells whether unused global variables should be treated as a
353 violation. [default: yes]
354
355
357 --defining-attr-methods=<method names>
358 List of method names used to declare (i.e. assign) instance
359 attributes. [default: __init__,__new__,setUp]
360
361 --valid-classmethod-first-arg=<argument names>
362 List of valid names for the first argument in a class method.
363 [default: cls]
364
365 --valid-metaclass-classmethod-first-arg=<argument names>
366 List of valid names for the first argument in a metaclass class
367 method. [default: cls]
368
369 --exclude-protected=<protected access exclusions>
370 List of member names, which should be excluded from the pro‐
371 tected access warning. [default:
372 _asdict,_fields,_replace,_source,_make]
373
374
376 --spelling-dict=<dict name>
377 Spelling dictionary name. Available dictionaries: none. To make
378 it work, install the python-enchant package. [default: none]
379
380 --spelling-ignore-words=<comma separated words>
381 List of comma separated words that should not be checked.
382 [default: none]
383
384 --spelling-private-dict-file=<path to file>
385 A path to a file that contains the private dictionary; one word
386 per line. [default: none]
387
388 --spelling-store-unknown-words=<y_or_n>
389 Tells whether to store unknown words to the private dictionary
390 (see the --spelling-private-dict-file option) instead of raising
391 a message. [default: no]
392
393 --max-spelling-suggestions=N
394 Limits count of emitted suggestions for spelling mistakes.
395 [default: 4]
396
397
399 --max-line-length=<int>
400 Maximum number of characters on a single line. [default: 100]
401
402 --ignore-long-lines=<regexp>
403 Regexp for a line that is allowed to be longer than the limit.
404 [default: ^\s*(# )?<?https?://\S+>?$]
405
406 --single-line-if-stmt=<y_or_n>
407 Allow the body of an if to be on the same line as the test if
408 there is no else. [default: no]
409
410 --single-line-class-stmt=<y_or_n>
411 Allow the body of a class to be on the same line as the declara‐
412 tion if body contains single statement. [default: no]
413
414 --no-space-check=trailing-comma,dict-separator,empty-line
415 List of optional constructs for which whitespace checking is
416 disabled. `dict-separator` is used to allow tabulation in dicts,
417 etc.: {1 : 1,\n222: 2}. `trailing-comma` allows a space between
418 comma and closing bracket: (a, ). `empty-line` allows space-only
419 lines. [default: trailing-comma,dict-separator]
420
421 --max-module-lines=<int>
422 Maximum number of lines in a module. [default: 1000]
423
424 --indent-string=<string>
425 String used as indentation unit. This is usually " " (4 spa‐
426 ces) or "\t" (1 tab). [default: ' ']
427
428 --indent-after-paren=<int>
429 Number of spaces of indent required inside a hanging or contin‐
430 ued line. [default: 4]
431
432 --expected-line-ending-format=<empty or LF or CRLF>
433 Expected format of line ending, e.g. empty (any line ending), LF
434 or CRLF. [default: none]
435
436
438 --good-names=<names>
439 Good variable names which should always be accepted, separated
440 by a comma. [default: i,j,k,ex,Run,_]
441
442 --bad-names=<names>
443 Bad variable names which should always be refused, separated by
444 a comma. [default: foo,bar,baz,toto,tutu,tata]
445
446 --name-group=<name1:name2>
447 Colon-delimited sets of names that determine each other's naming
448 style when the name regexes allow several styles. [default:
449 none]
450
451 --include-naming-hint=<y_or_n>
452 Include a hint for the correct naming format with invalid-name.
453 [default: no]
454
455 --property-classes=<decorator names>
456 List of decorators that produce properties, such as
457 abc.abstractproperty. Add to this list to register other decora‐
458 tors that produce valid properties. These decorators are taken
459 in consideration only for invalid-name. [default: abc.abstract‐
460 property]
461
462 --argument-naming-style=<style>
463 Naming style matching correct argument names. [default:
464 snake_case]
465
466 --argument-rgx=<regexp>
467 Regular expression matching correct argument names. Overrides
468 argument-naming-style.
469
470 --attr-naming-style=<style>
471 Naming style matching correct attribute names. [default:
472 snake_case]
473
474 --attr-rgx=<regexp>
475 Regular expression matching correct attribute names. Overrides
476 attr-naming-style.
477
478 --class-naming-style=<style>
479 Naming style matching correct class names. [default: PascalCase]
480
481 --class-rgx=<regexp>
482 Regular expression matching correct class names. Overrides
483 class-naming-style.
484
485 --class-attribute-naming-style=<style>
486 Naming style matching correct class attribute names. [default:
487 any]
488
489 --class-attribute-rgx=<regexp>
490 Regular expression matching correct class attribute names. Over‐
491 rides class-attribute-naming-style.
492
493 --const-naming-style=<style>
494 Naming style matching correct constant names. [default:
495 UPPER_CASE]
496
497 --const-rgx=<regexp>
498 Regular expression matching correct constant names. Overrides
499 const-naming-style.
500
501 --function-naming-style=<style>
502 Naming style matching correct function names. [default:
503 snake_case]
504
505 --function-rgx=<regexp>
506 Regular expression matching correct function names. Overrides
507 function-naming-style.
508
509 --inlinevar-naming-style=<style>
510 Naming style matching correct inline iteration names. [default:
511 any]
512
513 --inlinevar-rgx=<regexp>
514 Regular expression matching correct inline iteration names.
515 Overrides inlinevar-naming-style.
516
517 --method-naming-style=<style>
518 Naming style matching correct method names. [default:
519 snake_case]
520
521 --method-rgx=<regexp>
522 Regular expression matching correct method names. Overrides
523 method-naming-style.
524
525 --module-naming-style=<style>
526 Naming style matching correct module names. [default:
527 snake_case]
528
529 --module-rgx=<regexp>
530 Regular expression matching correct module names. Overrides mod‐
531 ule-naming-style.
532
533 --variable-naming-style=<style>
534 Naming style matching correct variable names. [default:
535 snake_case]
536
537 --variable-rgx=<regexp>
538 Regular expression matching correct variable names. Overrides
539 variable-naming-style.
540
541 --no-docstring-rgx=<regexp>
542 Regular expression which should only match function or class
543 names that do not require a docstring. [default: ^_]
544
545 --docstring-min-length=<int>
546 Minimum line length for functions/classes that require doc‐
547 strings, shorter ones are exempt. [default: -1]
548
549
551 --notes=<comma separated values>
552 List of note tags to take in consideration, separated by a
553 comma. [default: FIXME,XXX,TODO]
554
555
557 --max-args=<int>
558 Maximum number of arguments for function / method. [default: 5]
559
560 --max-locals=<int>
561 Maximum number of locals for function / method body. [default:
562 15]
563
564 --max-returns=<int>
565 Maximum number of return / yield for function / method body.
566 [default: 6]
567
568 --max-branches=<int>
569 Maximum number of branch for function / method body. [default:
570 12]
571
572 --max-statements=<int>
573 Maximum number of statements in function / method body.
574 [default: 50]
575
576 --max-parents=<num>
577 Maximum number of parents for a class (see R0901). [default: 7]
578
579 --max-attributes=<num>
580 Maximum number of attributes for a class (see R0902). [default:
581 7]
582
583 --min-public-methods=<num>
584 Minimum number of public methods for a class (see R0903).
585 [default: 2]
586
587 --max-public-methods=<num>
588 Maximum number of public methods for a class (see R0904).
589 [default: 20]
590
591 --max-bool-expr=<num>
592 Maximum number of boolean expressions in an if statement (see
593 R0916). [default: 5]
594
595
597 --max-nested-blocks=<int>
598 Maximum number of nested blocks for function / method body
599 [default: 5]
600
601 --never-returning-functions=NEVER_RETURNING_FUNCTIONS
602 Complete name of functions that never returns. When checking for
603 inconsistent-return-statements if a never returning function is
604 called then it will be considered as an explicit return state‐
605 ment and no message will be printed. [default: sys.exit]
606
607
609 --check-str-concat-over-line-jumps=<y_or_n>
610 This flag controls whether the implicit-str-concat-in-sequence
611 should generate a warning on implicit string concatenation in
612 sequences defined over several lines. [default: no]
613
614
616 The following environment variables are used:
617 * PYLINTHOME
618 Path to the directory where persistent data for the run will be
619 stored. If not found, it defaults to ~/.pylint.d/ or .pylint.d (in the
620 current working directory).
621 * PYLINTRC
622 Path to the configuration file. See the documentation for the
623 method used to search for configuration file.
624
625
627 Using the default text output, the message format is :
628
629 MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
630
631 There are 5 kind of message types :
632 * (C) convention, for programming standard violation
633 * (R) refactor, for bad code smell
634 * (W) warning, for python specific problems
635 * (E) error, for probable bugs in the code
636 * (F) fatal, if an error occurred which prevented pylint from doing
637 further processing.
638
639
641 Pylint should leave with following status code:
642 * 0 if everything went fine
643 * 1 if a fatal message was issued
644 * 2 if an error message was issued
645 * 4 if a warning message was issued
646 * 8 if a refactor message was issued
647 * 16 if a convention message was issued
648 * 32 on usage error
649
650 status 1 to 16 will be bit-ORed so you can know which different cate‐
651 gories has been issued by analysing pylint output status code
652
653
655 /usr/share/doc/pythonX.Y-pylint/
656
657
659 Please report bugs on the project's mailing list: mailto:code-qual‐
660 ity@python.org
661
662
664 Python Code Quality Authority <code-quality@python.org>
665
666
667
668
669pylint 2019-06-29 pylint(1)