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