1pylint(1)                   General Commands Manual                  pylint(1)
2
3
4

NAME

6       pylint - python code static checker
7
8

SYNOPSIS

10       pylint [ OPTIONS ] [ <arguments> ]
11
12

DESCRIPTION

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

OPTIONS

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

MASTER

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  modules
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       --extension-pkg-whitelist=<pkg[,pkg]>
84              A comma-separated list of package or module names from  where  C
85              extensions may be loaded. Extensions are loading into the active
86              Python interpreter and may run arbitrary code [default: none]
87
88       --suggestion-mode=<yn>
89              When enabled, pylint would attempt to guess common misconfigura‐
90              tion  and  emit  user-friendly  hints  instead of false-positive
91              error messages [default: yes]
92
93       --exit-zero
94              Always return a 0 (non-error) status code, even if  lint  errors
95              are  found.  This  is primarily useful in continuous integration
96              scripts.
97
98

COMMANDS

100       --help-msg=<msg-id>
101              Display a help message for the given message id  and  exit.  The
102              value may be a comma separated list of message ids.
103
104       --list-msgs
105              Generate pylint's messages.
106
107       --list-conf-levels
108              Generate pylint's confidence levels.
109
110       --full-documentation
111              Generate pylint's full documentation.
112
113       --generate-rcfile
114              Generate  a  sample  configuration file according to the current
115              configuration. You can put other options before this one to  get
116              them in the generated configuration.
117
118

MESSAGES CONTROL

120       --confidence=<levels>
121              Only  show  warnings  with  the  listed confidence levels. Leave
122              empty  to  show  all.  Valid  levels:  HIGH,  INFERENCE,  INFER‐
123              ENCE_FAILURE, UNDEFINED [default: none]
124
125       --enable=<msg ids>, -e <msg ids>
126              Enable  the  message, report, category or checker with the given
127              id(s). You can either  give  multiple  identifier  separated  by
128              comma  (,) or put this option multiple time (only on the command
129              line, not in the configuration file where it should appear  only
130              once). See also the "--disable" option for examples.
131
132       --disable=<msg ids>, -d <msg ids>
133              Disable  the message, report, category or checker with the given
134              id(s). You can either give  multiple  identifiers  separated  by
135              comma (,) or put this option multiple times (only on the command
136              line, not in the configuration file where it should appear  only
137              once).You  can  also  use  "--disable=all" to disable everything
138              first and then reenable specific checks.  For  example,  if  you
139              want  to  run only the similarities checker, you can use "--dis‐
140              able=all --enable=similarities". If you want  to  run  only  the
141              classes  checker,  but have no Warning level messages displayed,
142              use"--disable=all --enable=classes --disable=W"
143
144

REPORTS

146       --output-format=<format>, -f <format>
147              Set the output format. Available formats  are  text,  parseable,
148              colorized,  json  and  msvs (visual studio). You can also give a
149              reporter   class,    e.g.    mypackage.mymodule.MyReporterClass.
150              [default: text]
151
152       --reports=<y_or_n>, -r <y_or_n>
153              Tells  whether  to  display  a  full report or only the messages
154              [default: no]
155
156       --evaluation=<python_expression>
157              Python expression which should return a note less than 10 (10 is
158              the highest note). You have access to the variables errors warn‐
159              ing, statement which respectively contain the number of errors /
160              warnings  messages  and the total number of statements analyzed.
161              This is used by the global evaluation report (RP0004). [default:
162              10.0  -  ((float(5  * error + warning + refactor + convention) /
163              statement) * 10)]
164
165       --score=<y_or_n>, -s <y_or_n>
166              Activate the evaluation score. [default: yes]
167
168       --msg-template=<template>
169              Template used to display messages. This is  a  python  new-style
170              format  string  used  to format the message information. See doc
171              for all details
172
173

BASIC

175       --good-names=<names>
176              Good variable names which should always be  accepted,  separated
177              by a comma [default: i,j,k,ex,Run,_]
178
179       --bad-names=<names>
180              Bad  variable names which should always be refused, separated by
181              a comma [default: foo,bar,baz,toto,tutu,tata]
182
183       --name-group=<name1:name2>
184              Colon-delimited sets of names that determine each other's naming
185              style  when  the  name  regexes  allow several styles. [default:
186              none]
187
188       --include-naming-hint=<y_or_n>
189              Include a hint for the correct naming format  with  invalid-name
190              [default: no]
191
192       --property-classes=<decorator names>
193              List   of   decorators   that   produce   properties,   such  as
194              abc.abstractproperty. Add to this list to register other decora‐
195              tors  that produce valid properties. [default: abc.abstractprop‐
196              erty]
197
198       --argument-naming-style=<style>
199              Naming  style  matching   correct   argument   names   [default:
200              snake_case]
201
202       --argument-rgx=<regexp>
203              Regular  expression  matching  correct argument names. Overrides
204              argument-naming-style
205
206       --attr-naming-style=<style>
207              Naming  style  matching  correct   attribute   names   [default:
208              snake_case]
209
210       --attr-rgx=<regexp>
211              Regular  expression  matching correct attribute names. Overrides
212              attr-naming-style
213
214       --class-naming-style=<style>
215              Naming style matching correct class names [default: PascalCase]
216
217       --class-rgx=<regexp>
218              Regular  expression  matching  correct  class  names.  Overrides
219              class-naming-style
220
221       --class-attribute-naming-style=<style>
222              Naming  style  matching  correct class attribute names [default:
223              any]
224
225       --class-attribute-rgx=<regexp>
226              Regular expression matching correct class attribute names. Over‐
227              rides class-attribute-naming-style
228
229       --const-naming-style=<style>
230              Naming   style   matching   correct   constant  names  [default:
231              UPPER_CASE]
232
233       --const-rgx=<regexp>
234              Regular expression matching correct  constant  names.  Overrides
235              const-naming-style
236
237       --function-naming-style=<style>
238              Naming   style   matching   correct   function  names  [default:
239              snake_case]
240
241       --function-rgx=<regexp>
242              Regular expression matching correct  function  names.  Overrides
243              function-naming-style
244
245       --inlinevar-naming-style=<style>
246              Naming  style  matching correct inline iteration names [default:
247              any]
248
249       --inlinevar-rgx=<regexp>
250              Regular expression  matching  correct  inline  iteration  names.
251              Overrides inlinevar-naming-style
252
253       --method-naming-style=<style>
254              Naming style matching correct method names [default: snake_case]
255
256       --method-rgx=<regexp>
257              Regular  expression  matching  correct  method  names. Overrides
258              method-naming-style
259
260       --module-naming-style=<style>
261              Naming style matching correct module names [default: snake_case]
262
263       --module-rgx=<regexp>
264              Regular expression matching correct module names. Overrides mod‐
265              ule-naming-style
266
267       --variable-naming-style=<style>
268              Naming   style   matching   correct   variable  names  [default:
269              snake_case]
270
271       --variable-rgx=<regexp>
272              Regular expression matching correct  variable  names.  Overrides
273              variable-naming-style
274
275       --no-docstring-rgx=<regexp>
276              Regular  expression  which  should  only match function or class
277              names that do not require a docstring. [default: ^_]
278
279       --docstring-min-length=<int>
280              Minimum line length  for  functions/classes  that  require  doc‐
281              strings, shorter ones are exempt. [default: -1]
282
283

CLASSES

285       --defining-attr-methods=<method names>
286              List  of  method  names  used  to declare (i.e. assign) instance
287              attributes. [default: __init__,__new__,setUp]
288
289       --valid-classmethod-first-arg=<argument names>
290              List of valid names for the first argument in  a  class  method.
291              [default: cls]
292
293       --valid-metaclass-classmethod-first-arg=<argument names>
294              List  of valid names for the first argument in a metaclass class
295              method. [default: cls]
296
297       --exclude-protected=<protected access exclusions>
298              List of member names, which should be  excluded  from  the  pro‐
299              tected            access            warning.           [default:
300              _asdict,_fields,_replace,_source,_make]
301
302

DESIGN

304       --max-args=<int>
305              Maximum number of arguments for function / method [default: 5]
306
307       --max-locals=<int>
308              Maximum number of locals for function /  method  body  [default:
309              15]
310
311       --max-returns=<int>
312              Maximum  number  of  return  /  yield for function / method body
313              [default: 6]
314
315       --max-branches=<int>
316              Maximum number of branch for function /  method  body  [default:
317              12]
318
319       --max-statements=<int>
320              Maximum number of statements in function / method body [default:
321              50]
322
323       --max-parents=<num>
324              Maximum number of parents for a class (see R0901). [default: 7]
325
326       --max-attributes=<num>
327              Maximum number of attributes for a class (see R0902).  [default:
328              7]
329
330       --min-public-methods=<num>
331              Minimum  number  of  public  methods  for  a  class (see R0903).
332              [default: 2]
333
334       --max-public-methods=<num>
335              Maximum number of  public  methods  for  a  class  (see  R0904).
336              [default: 20]
337
338       --max-bool-expr=<num>
339              Maximum  number  of  boolean  expressions  in  an  if  statement
340              [default: 5]
341
342

EXCEPTIONS

344       --overgeneral-exceptions=<comma-separated class names>
345              Exceptions that will emit a warning when being caught.  Defaults
346              to "Exception" [default: Exception]
347
348

FORMAT

350       --max-line-length=<int>
351              Maximum number of characters on a single line. [default: 100]
352
353       --ignore-long-lines=<regexp>
354              Regexp  for  a line that is allowed to be longer than the limit.
355              [default: ^\s*(# )?<?https?://\S+>?$]
356
357       --single-line-if-stmt=<y_or_n>
358              Allow the body of an if to be on the same line as  the  test  if
359              there is no else. [default: no]
360
361       --single-line-class-stmt=<y_or_n>
362              Allow the body of a class to be on the same line as the declara‐
363              tion if body contains single statement. [default: no]
364
365       --no-space-check=trailing-comma,dict-separator,empty-line
366              List of optional constructs for  which  whitespace  checking  is
367              disabled. `dict-separator` is used to allow tabulation in dicts,
368              etc.: {1  : 1,\n222: 2}. `trailing-comma` allows a space between
369              comma and closing bracket: (a, ). `empty-line` allows space-only
370              lines. [default: trailing-comma,dict-separator]
371
372       --max-module-lines=<int>
373              Maximum number of lines in a module [default: 1000]
374
375       --indent-string=<string>
376              String used as indentation unit. This is usually "    " (4  spa‐
377              ces) or "\t" (1 tab). [default: '    ']
378
379       --indent-after-paren=<int>
380              Number  of spaces of indent required inside a hanging or contin‐
381              ued line. [default: 4]
382
383       --expected-line-ending-format=<empty or LF or CRLF>
384              Expected format of line ending, e.g. empty (any line ending), LF
385              or CRLF. [default: none]
386
387

IMPORTS

389       --deprecated-modules=<modules>
390              Deprecated  modules  which  should  not  be used, separated by a
391              comma [default: optparse,tkinter.tix]
392
393       --import-graph=<file.dot>
394              Create a graph of every (i.e. internal and  external)  dependen‐
395              cies  in  the  given  file  (report RP0402 must not be disabled)
396              [default: none]
397
398       --ext-import-graph=<file.dot>
399              Create a graph  of  external  dependencies  in  the  given  file
400              (report RP0402 must not be disabled) [default: none]
401
402       --int-import-graph=<file.dot>
403              Create  a  graph  of  internal  dependencies  in  the given file
404              (report RP0402 must not be disabled) [default: none]
405
406       --known-standard-library=<modules>
407              Force import order to recognize a module as part of the standard
408              compatibility libraries. [default: none]
409
410       --known-third-party=<modules>
411              Force  import  order  to  recognize  a module as part of a third
412              party library. [default: enchant]
413
414       --analyse-fallback-blocks=<y_or_n>
415              Analyse import fallback blocks. This can be used to support both
416              Python 2 and 3 compatible code, which means that the block might
417              have code that exists only in one or another interpreter,  lead‐
418              ing to false positives when analysed. [default: no]
419
420       --allow-wildcard-with-all=<y_or_n>
421              Allow   wildcard  imports  from  modules  that  define  __all__.
422              [default: no]
423
424

LOGGING

426       --logging-modules=<comma separated list>
427              Logging modules to check that the string format arguments are in
428              logging function parameter format [default: logging]
429
430

MISCELLANEOUS

432       --notes=<comma separated values>
433              List  of  note  tags  to  take  in consideration, separated by a
434              comma. [default: FIXME,XXX,TODO]
435
436

REFACTORING

438       --max-nested-blocks=<int>
439              Maximum number of nested  blocks  for  function  /  method  body
440              [default: 5]
441
442       --never-returning-functions=NEVER_RETURNING_FUNCTIONS
443              Complete name of functions that never returns. When checking for
444              inconsistent-return-statements if a never returning function  is
445              called  then  it will be considered as an explicit return state‐
446              ment and no message will be printed. [default: sys.exit]
447
448

SIMILARITIES

450       --min-similarity-lines=<int>
451              Minimum lines number of a similarity. [default: 4]
452
453       --ignore-comments=<y or n>
454              Ignore comments when computing similarities. [default: yes]
455
456       --ignore-docstrings=<y or n>
457              Ignore docstrings when computing similarities. [default: yes]
458
459       --ignore-imports=<y or n>
460              Ignore imports when computing similarities. [default: no]
461
462

SPELLING

464       --spelling-dict=<dict name>
465              Spelling dictionary name. Available dictionaries: none. To  make
466              it working install python-enchant package. [default: none]
467
468       --spelling-ignore-words=<comma separated words>
469              List  of  comma  separated  words  that  should  not be checked.
470              [default: none]
471
472       --spelling-private-dict-file=<path to file>
473              A path to a file that contains private dictionary; one word  per
474              line. [default: none]
475
476       --spelling-store-unknown-words=<y_or_n>
477              Tells  whether  to store unknown words to indicated private dic‐
478              tionary in --spelling-private-dict-file option instead of  rais‐
479              ing a message. [default: no]
480
481       --max-spelling-suggestions=N
482              Limits  count  of  emitted  suggestions  for  spelling  mistakes
483              [default: 4]
484
485

TYPECHECK

487       --ignore-on-opaque-inference=<y_or_n>
488              This flag controls whether pylint should  warn  about  no-member
489              and  similar  checks  whenever an opaque object is returned when
490              inferring. The inference can return multiple  potential  results
491              while evaluating a Python object, but some branches might not be
492              evaluated, which results in partial inference. In that case,  it
493              might be useful to still emit no-member and other checks for the
494              rest of the inferred objects. [default: yes]
495
496       --ignore-mixin-members=<y_or_n>
497              Tells whether missing members accessed in mixin class should  be
498              ignored. A mixin class is detected if its name ends with "mixin"
499              (case insensitive). [default: yes]
500
501       --ignore-none=<y_or_n>
502              Tells whether to warn about missing members when  the  owner  of
503              the attribute is inferred to be None [default: yes]
504
505       --ignored-modules=<module names>
506              List  of  module names for which member attributes should not be
507              checked (useful for modules/projects where namespaces are manip‐
508              ulated during runtime and thus existing member attributes cannot
509              be deduced by static  analysis.  It  supports  qualified  module
510              names, as well as Unix pattern matching. [default: none]
511
512       --ignored-classes=<members names>
513              List  of  class  names for which member attributes should not be
514              checked (useful for classes with  dynamically  set  attributes).
515              This  supports  the  use  of  qualified  names.  [default:  opt‐
516              parse.Values,thread._local,_thread._local]
517
518       --generated-members=<members names>
519              List of members which are set dynamically and missed  by  pylint
520              inference  system, and so shouldn't trigger E1101 when accessed.
521              Python regular expressions are accepted. [default: none]
522
523       --contextmanager-decorators=<decorator names>
524              List of decorators that produce context managers, such  as  con‐
525              textlib.contextmanager. Add to this list to register other deco‐
526              rators that  produce  valid  context  managers.  [default:  con‐
527              textlib.contextmanager]
528
529       --missing-member-hint-distance=<member hint edit distance>
530              The minimum edit distance a name should have in order to be con‐
531              sidered a similar match for a missing member name. [default: 1]
532
533       --missing-member-max-choices=<member hint max choices>
534              The total number of similar names that should be taken  in  con‐
535              sideration  when  showing a hint for a missing member. [default:
536              1]
537
538       --missing-member-hint=<missing member hint>
539              Show a hint with possible names  when  a  member  name  was  not
540              found. The aspect of finding the hint is based on edit distance.
541              [default: yes]
542
543

VARIABLES

545       --init-import=<y_or_n>
546              Tells whether we should check  for  unused  import  in  __init__
547              files. [default: no]
548
549       --dummy-variables-rgx=<regexp>
550              A  regular expression matching the name of dummy variables (i.e.
551              expectedly  not   used).   [default:   _+$|(_[a-zA-Z0-9_]*[a-zA-
552              Z0-9]+?$)|dummy|^ignored_|^unused_]
553
554       --additional-builtins=<comma separated list>
555              List  of  additional  names  supposed to be defined in builtins.
556              Remember that you should avoid to define new builtins when  pos‐
557              sible. [default: none]
558
559       --callbacks=<callbacks>
560              List  of strings which can identify a callback function by name.
561              A callback name must start or end with  one  of  those  strings.
562              [default: cb_,_cb]
563
564       --redefining-builtins-modules=<comma separated list>
565              List  of  qualified module names which can have objects that can
566              redefine                   builtins.                   [default:
567              six.moves,past.builtins,future.builtins,builtins,io]
568
569       --ignored-argument-names=<regexp>
570              Argument  names  that  match  this  expression  will be ignored.
571              Default   to   name   with    leading    underscore    [default:
572              _.*|^ignored_|^unused_]
573
574       --allow-global-unused-variables=<y_or_n>
575              Tells  whether  unused  global  variables should be treated as a
576              violation. [default: yes]
577
578

ENVIRONMENT VARIABLES

580       The following environment variables are used:
581           * PYLINTHOME
582           Path to the directory where persistent data for  the  run  will  be
583       stored.  If not found, it defaults to ~/.pylint.d/ or .pylint.d (in the
584       current working directory).
585           * PYLINTRC
586           Path to the configuration  file.  See  the  documentation  for  the
587       method used to search for configuration file.
588
589

OUTPUT

591       Using the default text output, the message format is :
592
593               MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
594
595       There are 5 kind of message types :
596           * (C) convention, for programming standard violation
597           * (R) refactor, for bad code smell
598           * (W) warning, for python specific problems
599           * (E) error, for probable bugs in the code
600           * (F) fatal, if an error occurred which prevented pylint from doing
601       further processing.
602
603

OUTPUT STATUS CODE

605       Pylint should leave with following status code:
606           * 0 if everything went fine
607           * 1 if a fatal message was issued
608           * 2 if an error message was issued
609           * 4 if a warning message was issued
610           * 8 if a refactor message was issued
611           * 16 if a convention message was issued
612           * 32 on usage error
613
614       status 1 to 16 will be bit-ORed so you can know which  different  cate‐
615       gories has been issued by analysing pylint output status code
616
617

SEE ALSO

619       /usr/share/doc/pythonX.Y-pylint/
620
621

BUGS

623       Please  report  bugs  on  the project's mailing list: mailto:code-qual‐
624       ity@python.org
625
626

AUTHOR

628       Python Code Quality Authority <code-quality@python.org>
629
630
631
632
633pylint                            2018-06-13                         pylint(1)
Impressum