-
Notifications
You must be signed in to change notification settings - Fork 0
/
pylint
1650 lines (1477 loc) · 82.6 KB
/
pylint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Pylint global options and switches
----------------------------------
Pylint provides global options and switches.
General options
~~~~~~~~~~~~~~~
:rcfile:
Specify a configuration file.
:init-hook:
Python code to execute, usually for sys.path manipulation such as
pygtk.require().
:errors-only:
In error mode, checkers without error messages are disabled and for others,
only the ERROR messages are displayed, and no reports are done by default.
:py3k:
In Python 3 porting mode, all checkers will be disabled and only messages
emitted by the porting checker will be displayed.
:verbose:
In verbose mode, extra non-checker-related info will be displayed.
:ignore:
Add files or directories to the blacklist. They should be base names, not
paths.
Default: ``CVS``
:ignore-patterns:
Add files or directories matching the regex patterns to the blacklist. The
regex matches against base names, not paths.
:persistent:
Pickle collected data for later comparisons.
Default: ``yes``
:load-plugins:
List of plugins (as comma separated values of python modules names) to load,
usually to register additional checkers.
:jobs:
Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
number of processors available to use.
Default: ``1``
:unsafe-load-any-extension:
Allow loading of arbitrary C extensions. Extensions are imported into the
active Python interpreter and may run arbitrary code.
:limit-inference-results:
Control the amount of potential inferred values when inferring a single
object. This can help the performance when dealing with large functions or
complex, nested conditions.
Default: ``100``
:extension-pkg-whitelist:
A comma-separated list of package or module names from where C extensions may
be loaded. Extensions are loading into the active Python interpreter and may
run arbitrary code.
:suggestion-mode:
When enabled, pylint would attempt to guess common misconfiguration and emit
user-friendly hints instead of false-positive error messages.
Default: ``yes``
:exit-zero:
Always return a 0 (non-error) status code, even if lint errors are found.
This is primarily useful in continuous integration scripts.
:long-help:
more verbose help.
Commands options
~~~~~~~~~~~~~~~~
:help-msg:
Display a help message for the given message id and exit. The value may be a
comma separated list of message ids.
:list-msgs:
Generate pylint's messages.
:list-groups:
List pylint's message groups.
:list-conf-levels:
Generate pylint's confidence levels.
:full-documentation:
Generate pylint's full documentation.
:generate-rcfile:
Generate a sample configuration file according to the current configuration.
You can put other options before this one to get them in the generated
configuration.
:generate-man:
Generate pylint's man page.
Messages control options
~~~~~~~~~~~~~~~~~~~~~~~~
:confidence:
Only show warnings with the listed confidence levels. Leave empty to show
all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
:enable:
Enable the message, report, category or checker with the given id(s). You can
either give multiple identifier separated by comma (,) or put this option
multiple time (only on the command line, not in the configuration file where
it should appear only once). See also the "--disable" option for examples.
Default: ``c-extension-no-member``
:disable:
Disable the message, report, category or checker with the given id(s). You
can either give multiple identifiers separated by comma (,) or put this
option multiple times (only on the command line, not in the configuration
file where it should appear only once). You can also use "--disable=all" to
disable everything first and then reenable specific checks. For example, if
you want to run only the similarities checker, you can use "--disable=all
--enable=similarities". If you want to run only the classes checker, but have
no Warning level messages displayed, use "--disable=all --enable=classes
--disable=W".
Default: ``print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,non-ascii-bytes-literal,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,use-symbolic-message-instead,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,deprecated-itertools-function,deprecated-types-field,next-method-defined,dict-items-not-iterating,dict-keys-not-iterating,dict-values-not-iterating,deprecated-operator-function,deprecated-urllib-function,xreadlines-attribute,deprecated-sys-function,exception-escape,comprehension-escape``
Reports options
~~~~~~~~~~~~~~~
:output-format:
Set the output format. Available formats are text, parseable, colorized, json
and msvs (visual studio). You can also give a reporter class, e.g.
mypackage.mymodule.MyReporterClass.
Default: ``text``
:reports:
Tells whether to display a full report or only the messages.
:evaluation:
Python expression which should return a note less than 10 (10 is the highest
note). You have access to the variables errors warning, statement which
respectively contain the number of errors / warnings messages and the total
number of statements analyzed. This is used by the global evaluation report
(RP0004).
Default: ``10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)``
:score:
Activate the evaluation score.
Default: ``yes``
:msg-template:
Template used to display messages. This is a python new-style format string
used to format the message information. See doc for all details.
Pylint checkers' options and switches
-------------------------------------
Pylint checkers can provide three set of features:
* options that control their execution,
* messages that they can raise,
* reports that they can generate.
Below is a list of all checkers and their features.
Async checker
~~~~~~~~~~~~~
Verbatim name of the checker is ``async``.
Async checker Messages
^^^^^^^^^^^^^^^^^^^^^^
:not-async-context-manager (E1701): *Async context manager '%s' doesn't implement __aenter__ and __aexit__.*
Used when an async context manager is used with an object that does not
implement the async context management protocol. This message can't be emitted
when using Python < 3.5.
:yield-inside-async-function (E1700): *Yield inside async function*
Used when an `yield` or `yield from` statement is found inside an async
function. This message can't be emitted when using Python < 3.5.
Basic checker
~~~~~~~~~~~~~
Verbatim name of the checker is ``basic``.
Basic checker Options
^^^^^^^^^^^^^^^^^^^^^
:good-names:
Good variable names which should always be accepted, separated by a comma.
Default: ``i,j,k,ex,Run,_``
:bad-names:
Bad variable names which should always be refused, separated by a comma.
Default: ``foo,bar,baz,toto,tutu,tata``
:name-group:
Colon-delimited sets of names that determine each other's naming style when
the name regexes allow several styles.
:include-naming-hint:
Include a hint for the correct naming format with invalid-name.
:property-classes:
List of decorators that produce properties, such as abc.abstractproperty. Add
to this list to register other decorators that produce valid properties.
These decorators are taken in consideration only for invalid-name.
Default: ``abc.abstractproperty``
:argument-naming-style:
Naming style matching correct argument names.
Default: ``snake_case``
:argument-rgx:
Regular expression matching correct argument names. Overrides argument-
naming-style.
:attr-naming-style:
Naming style matching correct attribute names.
Default: ``snake_case``
:attr-rgx:
Regular expression matching correct attribute names. Overrides attr-naming-
style.
:class-naming-style:
Naming style matching correct class names.
Default: ``PascalCase``
:class-rgx:
Regular expression matching correct class names. Overrides class-naming-
style.
:class-attribute-naming-style:
Naming style matching correct class attribute names.
Default: ``any``
:class-attribute-rgx:
Regular expression matching correct class attribute names. Overrides class-
attribute-naming-style.
:const-naming-style:
Naming style matching correct constant names.
Default: ``UPPER_CASE``
:const-rgx:
Regular expression matching correct constant names. Overrides const-naming-
style.
:function-naming-style:
Naming style matching correct function names.
Default: ``snake_case``
:function-rgx:
Regular expression matching correct function names. Overrides function-
naming-style.
:inlinevar-naming-style:
Naming style matching correct inline iteration names.
Default: ``any``
:inlinevar-rgx:
Regular expression matching correct inline iteration names. Overrides
inlinevar-naming-style.
:method-naming-style:
Naming style matching correct method names.
Default: ``snake_case``
:method-rgx:
Regular expression matching correct method names. Overrides method-naming-
style.
:module-naming-style:
Naming style matching correct module names.
Default: ``snake_case``
:module-rgx:
Regular expression matching correct module names. Overrides module-naming-
style.
:variable-naming-style:
Naming style matching correct variable names.
Default: ``snake_case``
:variable-rgx:
Regular expression matching correct variable names. Overrides variable-
naming-style.
:no-docstring-rgx:
Regular expression which should only match function or class names that do
not require a docstring.
Default: ``^_``
:docstring-min-length:
Minimum line length for functions/classes that require docstrings, shorter
ones are exempt.
Default: ``-1``
Basic checker Messages
^^^^^^^^^^^^^^^^^^^^^^
:not-in-loop (E0103): *%r not properly in loop*
Used when break or continue keywords are used outside a loop.
:function-redefined (E0102): *%s already defined line %s*
Used when a function / class / method is redefined.
:continue-in-finally (E0116): *'continue' not supported inside 'finally' clause*
Emitted when the `continue` keyword is found inside a finally clause, which is
a SyntaxError.
:abstract-class-instantiated (E0110): *Abstract class %r with abstract methods instantiated*
Used when an abstract class with `abc.ABCMeta` as metaclass has abstract
methods and is instantiated.
:star-needs-assignment-target (E0114): *Can use starred expression only in assignment target*
Emitted when a star expression is not used in an assignment target.
:duplicate-argument-name (E0108): *Duplicate argument name %s in function definition*
Duplicate argument names in function definitions are syntax errors.
:return-in-init (E0101): *Explicit return in __init__*
Used when the special class method __init__ has an explicit return value.
:too-many-star-expressions (E0112): *More than one starred expression in assignment*
Emitted when there are more than one starred expressions (`*x`) in an
assignment. This is a SyntaxError.
:nonlocal-and-global (E0115): *Name %r is nonlocal and global*
Emitted when a name is both nonlocal and global.
:used-prior-global-declaration (E0118): *Name %r is used prior to global declaration*
Emitted when a name is used prior a global declaration, which results in an
error since Python 3.6. This message can't be emitted when using Python < 3.6.
:return-outside-function (E0104): *Return outside function*
Used when a "return" statement is found outside a function or method.
:return-arg-in-generator (E0106): *Return with argument inside generator*
Used when a "return" statement with an argument is found outside in a
generator function or method (e.g. with some "yield" statements). This message
can't be emitted when using Python >= 3.3.
:invalid-star-assignment-target (E0113): *Starred assignment target must be in a list or tuple*
Emitted when a star expression is used as a starred assignment target.
:bad-reversed-sequence (E0111): *The first reversed() argument is not a sequence*
Used when the first argument to reversed() builtin isn't a sequence (does not
implement __reversed__, nor __getitem__ and __len__
:nonexistent-operator (E0107): *Use of the non-existent %s operator*
Used when you attempt to use the C-style pre-increment or pre-decrement
operator -- and ++, which doesn't exist in Python.
:yield-outside-function (E0105): *Yield outside function*
Used when a "yield" statement is found outside a function or method.
:init-is-generator (E0100): *__init__ method is a generator*
Used when the special class method __init__ is turned into a generator by a
yield in its body.
:misplaced-format-function (E0119): *format function is not called on str*
Emitted when format function is not called on str object. e.g doing
print("value: {}").format(123) instead of print("value: {}".format(123)). This
might not be what the user intended to do.
:nonlocal-without-binding (E0117): *nonlocal name %s found without binding*
Emitted when a nonlocal variable does not have an attached name somewhere in
the parent scopes
:lost-exception (W0150): *%s statement in finally block may swallow exception*
Used when a break or a return statement is found inside the finally clause of
a try...finally block: the exceptions raised in the try clause will be
silently swallowed instead of being re-raised.
:assert-on-tuple (W0199): *Assert called on a 2-uple. Did you mean 'assert x,y'?*
A call of assert on a tuple will always evaluate to true if the tuple is not
empty, and will always evaluate to false if it is.
:comparison-with-callable (W0143): *Comparing against a callable, did you omit the parenthesis?*
This message is emitted when pylint detects that a comparison with a callable
was made, which might suggest that some parenthesis were omitted, resulting in
potential unwanted behaviour.
:dangerous-default-value (W0102): *Dangerous default value %s as argument*
Used when a mutable value as list or dictionary is detected in a default value
for an argument.
:duplicate-key (W0109): *Duplicate key %r in dictionary*
Used when a dictionary expression binds the same key multiple times.
:useless-else-on-loop (W0120): *Else clause on loop without a break statement*
Loops should only have an else clause if they can exit early with a break
statement, otherwise the statements under else should be on the same scope as
the loop itself.
:expression-not-assigned (W0106): *Expression "%s" is assigned to nothing*
Used when an expression that is not a function call is assigned to nothing.
Probably something else was intended.
:confusing-with-statement (W0124): *Following "as" with another context manager looks like a tuple.*
Emitted when a `with` statement component returns multiple values and uses
name binding with `as` only for a part of those values, as in with ctx() as a,
b. This can be misleading, since it's not clear if the context manager returns
a tuple or if the node without a name binding is another context manager.
:unnecessary-lambda (W0108): *Lambda may not be necessary*
Used when the body of a lambda expression is a function call on the same
argument list as the lambda itself; such lambda expressions are in all but a
few cases replaceable with the function being called in the body of the
lambda.
:assign-to-new-keyword (W0111): *Name %s will become a keyword in Python %s*
Used when assignment will become invalid in future Python release due to
introducing new keyword.
:pointless-statement (W0104): *Statement seems to have no effect*
Used when a statement doesn't have (or at least seems to) any effect.
:pointless-string-statement (W0105): *String statement has no effect*
Used when a string is used as a statement (which of course has no effect).
This is a particular case of W0104 with its own message so you can easily
disable it if you're using those strings as documentation, instead of
comments.
:unnecessary-pass (W0107): *Unnecessary pass statement*
Used when a "pass" statement that can be avoided is encountered.
:unreachable (W0101): *Unreachable code*
Used when there is some code behind a "return" or "raise" statement, which
will never be accessed.
:eval-used (W0123): *Use of eval*
Used when you use the "eval" function, to discourage its usage. Consider using
`ast.literal_eval` for safely evaluating strings containing Python expressions
from untrusted sources.
:exec-used (W0122): *Use of exec*
Used when you use the "exec" statement (function for Python 3), to discourage
its usage. That doesn't mean you cannot use it !
:using-constant-test (W0125): *Using a conditional statement with a constant value*
Emitted when a conditional statement (If or ternary if) uses a constant value
for its test. This might not be what the user intended to do.
:literal-comparison (R0123): *Comparison to literal*
Used when comparing an object to a literal, which is usually what you do not
want to do, since you can compare to a different literal than what was
expected altogether.
:comparison-with-itself (R0124): *Redundant comparison - %s*
Used when something is compared against itself.
:invalid-name (C0103): *%s name "%s" doesn't conform to %s*
Used when the name doesn't conform to naming rules associated to its type
(constant, variable, class...).
:blacklisted-name (C0102): *Black listed name "%s"*
Used when the name is listed in the black list (unauthorized names).
:misplaced-comparison-constant (C0122): *Comparison should be %s*
Used when the constant is placed on the left side of a comparison. It is
usually clearer in intent to place it in the right hand side of the
comparison.
:singleton-comparison (C0121): *Comparison to %s should be %s*
Used when an expression is compared to singleton values like True, False or
None.
:empty-docstring (C0112): *Empty %s docstring*
Used when a module, function, class or method has an empty docstring (it would
be too easy ;).
:missing-docstring (C0111): *Missing %s docstring*
Used when a module, function, class or method has no docstring.Some special
methods like __init__ doesn't necessary require a docstring.
:unidiomatic-typecheck (C0123): *Using type() instead of isinstance() for a typecheck.*
The idiomatic way to perform an explicit typecheck in Python is to use
isinstance(x, Y) rather than type(x) == Y, type(x) is Y. Though there are
unusual situations where these give different results.
Basic checker Reports
^^^^^^^^^^^^^^^^^^^^^
:RP0101: Statistics by type
Classes checker
~~~~~~~~~~~~~~~
Verbatim name of the checker is ``classes``.
Classes checker Options
^^^^^^^^^^^^^^^^^^^^^^^
:defining-attr-methods:
List of method names used to declare (i.e. assign) instance attributes.
Default: ``__init__,__new__,setUp``
:valid-classmethod-first-arg:
List of valid names for the first argument in a class method.
Default: ``cls``
:valid-metaclass-classmethod-first-arg:
List of valid names for the first argument in a metaclass class method.
Default: ``cls``
:exclude-protected:
List of member names, which should be excluded from the protected access
warning.
Default: ``_asdict,_fields,_replace,_source,_make``
Classes checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^
:access-member-before-definition (E0203): *Access to member %r before its definition line %s*
Used when an instance member is accessed before it's actually assigned.
:method-hidden (E0202): *An attribute defined in %s line %s hides this method*
Used when a class defines a method which is hidden by an instance attribute
from an ancestor class or set by some client code.
:assigning-non-slot (E0237): *Assigning to attribute %r not defined in class slots*
Used when assigning to an attribute not defined in the class slots.
:duplicate-bases (E0241): *Duplicate bases for class %r*
Used when a class has duplicate bases.
:inconsistent-mro (E0240): *Inconsistent method resolution order for class %r*
Used when a class has an inconsistent method resolution order.
:inherit-non-class (E0239): *Inheriting %r, which is not a class.*
Used when a class inherits from something which is not a class.
:invalid-slots (E0238): *Invalid __slots__ object*
Used when an invalid __slots__ is found in class. Only a string, an iterable
or a sequence is permitted.
:invalid-slots-object (E0236): *Invalid object %r in __slots__, must contain only non empty strings*
Used when an invalid (non-string) object occurs in __slots__.
:no-method-argument (E0211): *Method has no argument*
Used when a method which should have the bound instance as first argument has
no argument defined.
:no-self-argument (E0213): *Method should have "self" as first argument*
Used when a method has an attribute different the "self" as first argument.
This is considered as an error since this is a so common convention that you
shouldn't break it!
:unexpected-special-method-signature (E0302): *The special method %r expects %s param(s), %d %s given*
Emitted when a special method was defined with an invalid number of
parameters. If it has too few or too many, it might not work at all.
:non-iterator-returned (E0301): *__iter__ returns non-iterator*
Used when an __iter__ method returns something which is not an iterable (i.e.
has no `__next__` method)
:invalid-length-returned (E0303): *__len__ does not return non-negative integer*
Used when a __len__ method returns something which is not a non-negative
integer
:protected-access (W0212): *Access to a protected member %s of a client class*
Used when a protected member (i.e. class member with a name beginning with an
underscore) is access outside the class or a descendant of the class where
it's defined.
:attribute-defined-outside-init (W0201): *Attribute %r defined outside __init__*
Used when an instance attribute is defined outside the __init__ method.
:no-init (W0232): *Class has no __init__ method*
Used when a class has no __init__ method, neither its parent classes.
:abstract-method (W0223): *Method %r is abstract in class %r but is not overridden*
Used when an abstract method (i.e. raise NotImplementedError) is not
overridden in concrete class.
:arguments-differ (W0221): *Parameters differ from %s %r method*
Used when a method has a different number of arguments than in the implemented
interface or in an overridden method.
:signature-differs (W0222): *Signature differs from %s %r method*
Used when a method signature is different than in the implemented interface or
in an overridden method.
:bad-staticmethod-argument (W0211): *Static method with %r as first argument*
Used when a static method has "self" or a value specified in valid-
classmethod-first-arg option or valid-metaclass-classmethod-first-arg option
as first argument.
:useless-super-delegation (W0235): *Useless super delegation in method %r*
Used whenever we can detect that an overridden method is useless, relying on
super() delegation to do the same thing as another method from the MRO.
:non-parent-init-called (W0233): *__init__ method from a non direct base class %r is called*
Used when an __init__ method is called on a class which is not in the direct
ancestors for the analysed class.
:super-init-not-called (W0231): *__init__ method from base class %r is not called*
Used when an ancestor class method has an __init__ method which is not called
by a derived class.
:useless-object-inheritance (R0205): *Class %r inherits from object, can be safely removed from bases in python3*
Used when a class inherit from object, which under python3 is implicit, hence
can be safely removed from bases.
:no-classmethod-decorator (R0202): *Consider using a decorator instead of calling classmethod*
Used when a class method is defined without using the decorator syntax.
:no-staticmethod-decorator (R0203): *Consider using a decorator instead of calling staticmethod*
Used when a static method is defined without using the decorator syntax.
:no-self-use (R0201): *Method could be a function*
Used when a method doesn't use its bound instance, and so could be written as
a function.
:single-string-used-for-slots (C0205): *Class __slots__ should be a non-string iterable*
Used when a class __slots__ is a simple string, rather than an iterable.
:bad-classmethod-argument (C0202): *Class method %s should have %s as first argument*
Used when a class method has a first argument named differently than the value
specified in valid-classmethod-first-arg option (default to "cls"),
recommended to easily differentiate them from regular instance methods.
:bad-mcs-classmethod-argument (C0204): *Metaclass class method %s should have %s as first argument*
Used when a metaclass class method has a first argument named differently than
the value specified in valid-metaclass-classmethod-first-arg option (default
to "mcs"), recommended to easily differentiate them from regular instance
methods.
:bad-mcs-method-argument (C0203): *Metaclass method %s should have %s as first argument*
Used when a metaclass method has a first argument named differently than the
value specified in valid-classmethod-first-arg option (default to "cls"),
recommended to easily differentiate them from regular instance methods.
:method-check-failed (F0202): *Unable to check methods signature (%s / %s)*
Used when Pylint has been unable to check methods signature compatibility for
an unexpected reason. Please report this kind if you don't make sense of it.
Design checker
~~~~~~~~~~~~~~
Verbatim name of the checker is ``design``.
Design checker Options
^^^^^^^^^^^^^^^^^^^^^^
:max-args:
Maximum number of arguments for function / method.
Default: ``5``
:max-locals:
Maximum number of locals for function / method body.
Default: ``15``
:max-returns:
Maximum number of return / yield for function / method body.
Default: ``6``
:max-branches:
Maximum number of branch for function / method body.
Default: ``12``
:max-statements:
Maximum number of statements in function / method body.
Default: ``50``
:max-parents:
Maximum number of parents for a class (see R0901).
Default: ``7``
:max-attributes:
Maximum number of attributes for a class (see R0902).
Default: ``7``
:min-public-methods:
Minimum number of public methods for a class (see R0903).
Default: ``2``
:max-public-methods:
Maximum number of public methods for a class (see R0904).
Default: ``20``
:max-bool-expr:
Maximum number of boolean expressions in an if statement.
Default: ``5``
Design checker Messages
^^^^^^^^^^^^^^^^^^^^^^^
:too-few-public-methods (R0903): *Too few public methods (%s/%s)*
Used when class has too few public methods, so be sure it's really worth it.
:too-many-ancestors (R0901): *Too many ancestors (%s/%s)*
Used when class has too many parent classes, try to reduce this to get a
simpler (and so easier to use) class.
:too-many-arguments (R0913): *Too many arguments (%s/%s)*
Used when a function or method takes too many arguments.
:too-many-boolean-expressions (R0916): *Too many boolean expressions in if statement (%s/%s)*
Used when an if statement contains too many boolean expressions.
:too-many-branches (R0912): *Too many branches (%s/%s)*
Used when a function or method has too many branches, making it hard to
follow.
:too-many-instance-attributes (R0902): *Too many instance attributes (%s/%s)*
Used when class has too many instance attributes, try to reduce this to get a
simpler (and so easier to use) class.
:too-many-locals (R0914): *Too many local variables (%s/%s)*
Used when a function or method has too many local variables.
:too-many-public-methods (R0904): *Too many public methods (%s/%s)*
Used when class has too many public methods, try to reduce this to get a
simpler (and so easier to use) class.
:too-many-return-statements (R0911): *Too many return statements (%s/%s)*
Used when a function or method has too many return statement, making it hard
to follow.
:too-many-statements (R0915): *Too many statements (%s/%s)*
Used when a function or method has too many statements. You should then split
it in smaller functions / methods.
Exceptions checker
~~~~~~~~~~~~~~~~~~
Verbatim name of the checker is ``exceptions``.
Exceptions checker Options
^^^^^^^^^^^^^^^^^^^^^^^^^^
:overgeneral-exceptions:
Exceptions that will emit a warning when being caught. Defaults to
"BaseException, Exception".
Default: ``BaseException,Exception``
Exceptions checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^^^^
:bad-except-order (E0701): *Bad except clauses order (%s)*
Used when except clauses are not in the correct order (from the more specific
to the more generic). If you don't fix the order, some exceptions may not be
caught by the most specific handler.
:catching-non-exception (E0712): *Catching an exception which doesn't inherit from Exception: %s*
Used when a class which doesn't inherit from Exception is used as an exception
in an except clause.
:bad-exception-context (E0703): *Exception context set to something which is not an exception, nor None*
Used when using the syntax "raise ... from ...", where the exception context
is not an exception, nor None.
:notimplemented-raised (E0711): *NotImplemented raised - should raise NotImplementedError*
Used when NotImplemented is raised instead of NotImplementedError
:raising-bad-type (E0702): *Raising %s while only classes or instances are allowed*
Used when something which is neither a class, an instance or a string is
raised (i.e. a `TypeError` will be raised).
:raising-non-exception (E0710): *Raising a new style class which doesn't inherit from BaseException*
Used when a new style class which doesn't inherit from BaseException is
raised.
:misplaced-bare-raise (E0704): *The raise statement is not inside an except clause*
Used when a bare raise is not used inside an except clause. This generates an
error, since there are no active exceptions to be reraised. An exception to
this rule is represented by a bare raise inside a finally clause, which might
work, as long as an exception is raised inside the try block, but it is
nevertheless a code smell that must not be relied upon.
:duplicate-except (W0705): *Catching previously caught exception type %s*
Used when an except catches a type that was already caught by a previous
handler.
:broad-except (W0703): *Catching too general exception %s*
Used when an except catches a too general exception, possibly burying
unrelated errors.
:raising-format-tuple (W0715): *Exception arguments suggest string formatting might be intended*
Used when passing multiple arguments to an exception constructor, the first of
them a string literal containing what appears to be placeholders intended for
formatting
:binary-op-exception (W0711): *Exception to catch is the result of a binary "%s" operation*
Used when the exception to catch is of the form "except A or B:". If intending
to catch multiple, rewrite as "except (A, B):"
:wrong-exception-operation (W0716): *Invalid exception operation. %s*
Used when an operation is done against an exception, but the operation is not
valid for the exception in question. Usually emitted when having binary
operations between exceptions in except handlers.
:bare-except (W0702): *No exception type(s) specified*
Used when an except clause doesn't specify exceptions type to catch.
:try-except-raise (W0706): *The except handler raises immediately*
Used when an except handler uses raise as its first or only operator. This is
useless because it raises back the exception immediately. Remove the raise
operator or the entire try-except-raise block!
Format checker
~~~~~~~~~~~~~~
Verbatim name of the checker is ``format``.
Format checker Options
^^^^^^^^^^^^^^^^^^^^^^
:max-line-length:
Maximum number of characters on a single line.
Default: ``100``
:ignore-long-lines:
Regexp for a line that is allowed to be longer than the limit.
Default: ``^\s*(# )?<?https?://\S+>?$``
:single-line-if-stmt:
Allow the body of an if to be on the same line as the test if there is no
else.
:single-line-class-stmt:
Allow the body of a class to be on the same line as the declaration if body
contains single statement.
:no-space-check:
List of optional constructs for which whitespace checking is disabled. `dict-
separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
`trailing-comma` allows a space between comma and closing bracket: (a, ).
`empty-line` allows space-only lines.
Default: ``trailing-comma,dict-separator``
:max-module-lines:
Maximum number of lines in a module.
Default: ``1000``
:indent-string:
String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
tab).
Default: ``' '``
:indent-after-paren:
Number of spaces of indent required inside a hanging or continued line.
Default: ``4``
:expected-line-ending-format:
Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
Format checker Messages
^^^^^^^^^^^^^^^^^^^^^^^
:bad-indentation (W0311): *Bad indentation. Found %s %s, expected %s*
Used when an unexpected number of indentation's tabulations or spaces has been
found.
:mixed-indentation (W0312): *Found indentation with %ss instead of %ss*
Used when there are some mixed tabs and spaces in a module.
:unnecessary-semicolon (W0301): *Unnecessary semicolon*
Used when a statement is ended by a semi-colon (";"), which isn't necessary
(that's python, not C ;).
:bad-whitespace (C0326): *%s space %s %s %s*
Used when a wrong number of spaces is used around an operator, bracket or
block opener.
:missing-final-newline (C0304): *Final newline missing*
Used when the last line in a file is missing a newline.
:line-too-long (C0301): *Line too long (%s/%s)*
Used when a line is longer than a given number of characters.
:mixed-line-endings (C0327): *Mixed line endings LF and CRLF*
Used when there are mixed (LF and CRLF) newline signs in a file.
:multiple-statements (C0321): *More than one statement on a single line*
Used when more than on statement are found on the same line.
:too-many-lines (C0302): *Too many lines in module (%s/%s)*
Used when a module has too many lines, reducing its readability.
:trailing-newlines (C0305): *Trailing newlines*
Used when there are trailing blank lines in a file.
:trailing-whitespace (C0303): *Trailing whitespace*
Used when there is whitespace between the end of a line and the newline.
:unexpected-line-ending-format (C0328): *Unexpected line ending format. There is '%s' while it should be '%s'.*
Used when there is different newline than expected.
:superfluous-parens (C0325): *Unnecessary parens after %r keyword*
Used when a single item in parentheses follows an if, for, or other keyword.
:bad-continuation (C0330): *Wrong %s indentation%s%s.*
TODO
Imports checker
~~~~~~~~~~~~~~~
Verbatim name of the checker is ``imports``.
Imports checker Options
^^^^^^^^^^^^^^^^^^^^^^^
:deprecated-modules:
Deprecated modules which should not be used, separated by a comma.
Default: ``optparse,tkinter.tix``
:import-graph:
Create a graph of every (i.e. internal and external) dependencies in the
given file (report RP0402 must not be disabled).
:ext-import-graph:
Create a graph of external dependencies in the given file (report RP0402 must
not be disabled).
:int-import-graph:
Create a graph of internal dependencies in the given file (report RP0402 must
not be disabled).
:known-standard-library:
Force import order to recognize a module as part of the standard
compatibility libraries.
:known-third-party:
Force import order to recognize a module as part of a third party library.
Default: ``enchant``
:analyse-fallback-blocks:
Analyse import fallback blocks. This can be used to support both Python 2 and
3 compatible code, which means that the block might have code that exists
only in one or another interpreter, leading to false positives when analysed.
:allow-wildcard-with-all:
Allow wildcard imports from modules that define __all__.
Imports checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^
:relative-beyond-top-level (E0402): *Attempted relative import beyond top-level package*
Used when a relative import tries to access too many levels in the current
package.
:import-error (E0401): *Unable to import %s*
Used when pylint has been unable to import a module.
:import-self (W0406): *Module import itself*
Used when a module is importing itself.
:reimported (W0404): *Reimport %r (imported line %s)*
Used when a module is reimported multiple times.
:relative-import (W0403): *Relative import %r, should be %r*
Used when an import relative to the package directory is detected. This
message can't be emitted when using Python >= 3.0.
:deprecated-module (W0402): *Uses of a deprecated module %r*
Used a module marked as deprecated is imported.
:wildcard-import (W0401): *Wildcard import %s*
Used when `from module import *` is detected.
:misplaced-future (W0410): *__future__ import is not the first non docstring statement*
Python 2.5 and greater require __future__ import to be the first non docstring
statement in the module.
:cyclic-import (R0401): *Cyclic import (%s)*
Used when a cyclic import between two or more modules is detected.
:wrong-import-order (C0411): *%s should be placed before %s*
Used when PEP8 import order is not respected (standard imports first, then
third-party libraries, then local imports)
:wrong-import-position (C0413): *Import "%s" should be placed at the top of the module*
Used when code and imports are mixed
:useless-import-alias (C0414): *Import alias does not rename original package*
Used when an import alias is same as original package.e.g using import numpy
as numpy instead of import numpy as np
:ungrouped-imports (C0412): *Imports from package %s are not grouped*
Used when imports are not grouped by packages
:multiple-imports (C0410): *Multiple imports on one line (%s)*
Used when import statement importing multiple modules is detected.
Imports checker Reports
^^^^^^^^^^^^^^^^^^^^^^^
:RP0401: External dependencies
:RP0402: Modules dependencies graph
Logging checker
~~~~~~~~~~~~~~~
Verbatim name of the checker is ``logging``.
Logging checker Options
^^^^^^^^^^^^^^^^^^^^^^^
:logging-modules:
Logging modules to check that the string format arguments are in logging
function parameter format.
Default: ``logging``
:logging-format-style:
Format style used to check logging format string. `old` means using %
formatting, while `new` is for `{}` formatting.
Default: ``old``
Logging checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^
:logging-format-truncated (E1201): *Logging format string ends in middle of conversion specifier*
Used when a logging statement format string terminates before the end of a
conversion specifier.
:logging-too-few-args (E1206): *Not enough arguments for logging format string*
Used when a logging format string is given too few arguments.
:logging-too-many-args (E1205): *Too many arguments for logging format string*
Used when a logging format string is given too many arguments.
:logging-unsupported-format (E1200): *Unsupported logging format character %r (%#02x) at index %d*
Used when an unsupported format character is used in a logging statement
format string.
:logging-not-lazy (W1201): *Specify string format arguments as logging function parameters*
Used when a logging statement has a call form of "logging.<logging
method>(format_string % (format_args...))". Such calls should leave string
interpolation to the logging method itself and be written "logging.<logging
method>(format_string, format_args...)" so that the program may avoid
incurring the cost of the interpolation in those cases in which no message
will be logged. For more, see http://www.python.org/dev/peps/pep-0282/.
:logging-format-interpolation (W1202): *Use % formatting in logging functions and pass the % parameters as arguments*
Used when a logging statement has a call form of "logging.<logging
method>(format_string.format(format_args...))". Such calls should use %
formatting instead, but leave interpolation to the logging function by passing
the parameters as arguments.
:logging-fstring-interpolation (W1203): *Use % formatting in logging functions and pass the % parameters as arguments*
Used when a logging statement has a call form of "logging.method(f"..."))".
Such calls should use % formatting instead, but leave interpolation to the
logging function by passing the parameters as arguments.
Metrics checker
~~~~~~~~~~~~~~~
Verbatim name of the checker is ``metrics``.
Metrics checker Reports
^^^^^^^^^^^^^^^^^^^^^^^
:RP0701: Raw metrics
Miscellaneous checker
~~~~~~~~~~~~~~~~~~~~~
Verbatim name of the checker is ``miscellaneous``.
Miscellaneous checker Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:notes:
List of note tags to take in consideration, separated by a comma.
Default: ``FIXME,XXX,TODO``
Miscellaneous checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:fixme (W0511):
Used when a warning note as FIXME or XXX is detected.
:invalid-encoded-data (W0512): *Cannot decode using encoding "%s", unexpected byte at position %d*
Used when a source line cannot be decoded using the specified source file
encoding. This message can't be emitted when using Python >= 3.0.
:use-symbolic-message-instead (I0023):
Used when a message is enabled or disabled by id.
Newstyle checker
~~~~~~~~~~~~~~~~
Verbatim name of the checker is ``newstyle``.
Newstyle checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^^
:bad-super-call (E1003): *Bad first argument %r given to super()*
Used when another argument than the current class is given as first argument
of the super builtin.
:missing-super-argument (E1004): *Missing argument to super()*
Used when the super builtin didn't receive an argument. This message can't be
emitted when using Python >= 3.0.
Python3 checker
~~~~~~~~~~~~~~~
Verbatim name of the checker is ``python3``.
Python3 checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^
:unpacking-in-except (E1603): *Implicit unpacking of exceptions is not supported in Python 3*
Python3 will not allow implicit unpacking of exceptions in except clauses. See
http://www.python.org/dev/peps/pep-3110/
:import-star-module-level (E1609): *Import * only allowed at module level*
Used when the import star syntax is used somewhere else than the module level.
This message can't be emitted when using Python >= 3.0.
:non-ascii-bytes-literal (E1610): *Non-ascii bytes literals not supported in 3.x*
Used when non-ascii bytes literals are found in a program. They are no longer
supported in Python 3. This message can't be emitted when using Python >= 3.0.
:parameter-unpacking (E1602): *Parameter unpacking specified*
Used when parameter unpacking is specified for a function(Python 3 doesn't
allow it)
:long-suffix (E1606): *Use of long suffix*
Used when "l" or "L" is used to mark a long integer. This will not work in
Python 3, since `int` and `long` types have merged. This message can't be
emitted when using Python >= 3.0.
:old-octal-literal (E1608): *Use of old octal literal*
Used when encountering the old octal syntax, removed in Python 3. To use the
new syntax, prepend 0o on the number. This message can't be emitted when using
Python >= 3.0.
:old-ne-operator (E1607): *Use of the <> operator*
Used when the deprecated "<>" operator is used instead of "!=". This is
removed in Python 3. This message can't be emitted when using Python >= 3.0.
:backtick (E1605): *Use of the `` operator*
Used when the deprecated "``" (backtick) operator is used instead of the str()
function.
:old-raise-syntax (E1604): *Use raise ErrorClass(args) instead of raise ErrorClass, args.*
Used when the alternate raise syntax 'raise foo, bar' is used instead of
'raise foo(bar)'.
:print-statement (E1601): *print statement used*
Used when a print statement is used (`print` is a function in Python 3)
:deprecated-types-field (W1652): *Accessing a deprecated fields on the types module*
Used when accessing a field on types that has been removed in Python 3.
:deprecated-itertools-function (W1651): *Accessing a deprecated function on the itertools module*
Used when accessing a function on itertools that has been removed in Python 3.
:deprecated-string-function (W1649): *Accessing a deprecated function on the string module*
Used when accessing a string function that has been deprecated in Python 3.
:deprecated-operator-function (W1657): *Accessing a removed attribute on the operator module*
Used when accessing a field on operator module that has been removed in Python
3.
:deprecated-sys-function (W1660): *Accessing a removed attribute on the sys module*
Used when accessing a field on sys module that has been removed in Python 3.
:deprecated-urllib-function (W1658): *Accessing a removed attribute on the urllib module*
Used when accessing a field on urllib module that has been removed or moved in
Python 3.
:xreadlines-attribute (W1659): *Accessing a removed xreadlines attribute*
Used when accessing the xreadlines() function on a file stream, removed in
Python 3.
:metaclass-assignment (W1623): *Assigning to a class's __metaclass__ attribute*
Used when a metaclass is specified by assigning to __metaclass__ (Python 3
specifies the metaclass as a class statement argument)
:next-method-called (W1622): *Called a next() method on an object*
Used when an object's next() method is called (Python 3 uses the next() built-
in function)
:dict-iter-method (W1620): *Calling a dict.iter*() method*
Used for calls to dict.iterkeys(), itervalues() or iteritems() (Python 3 lacks
these methods)
:dict-view-method (W1621): *Calling a dict.view*() method*
Used for calls to dict.viewkeys(), viewvalues() or viewitems() (Python 3 lacks
these methods)
:exception-message-attribute (W1645): *Exception.message removed in Python 3*
Used when the message attribute is accessed on an Exception. Use
str(exception) instead.
:eq-without-hash (W1641): *Implementing __eq__ without also implementing __hash__*
Used when a class implements __eq__ but not __hash__. In Python 2, objects get
object.__hash__ as the default implementation, in Python 3 objects get None as