Browse Source

Enable pylint in horizon

tests.py files are excluded from targets checked by pylint
because it takes longer and longer time to check them somehow.

pylint 2.2.x is supported only in Python 3 and we already switched
our pep8 basepython to python3, so pylint and astroid are installed
only for python3. This seems the easiest way to ensure py27 env works.

literal-comparison error in openstack_dashboard/api/nova.py
is also fixed in this commit as it is simple enough.

Change-Id: Ic8868a44b296dba457be721716ca6f9d37ad9369
tags/15.0.0.0b2
Akihiro Motoki 8 months ago
parent
commit
220b1346bd
4 changed files with 114 additions and 8 deletions
  1. 110
    7
      .pylintrc
  2. 1
    1
      openstack_dashboard/api/nova.py
  3. 2
    0
      test-requirements.txt
  4. 1
    0
      tox.ini

+ 110
- 7
.pylintrc View File

@@ -2,15 +2,106 @@
2 2
 [MASTER]
3 3
 # Add <file or directory> to the black list. It should be a base name, not a
4 4
 # path. You may set this option multiple times.
5
-ignore=test
5
+ignore=test,tests,tests.py,local_settings.py
6 6
 
7 7
 [Messages Control]
8
-# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future
9
-# C0111: Don't require docstrings on every method
10
-# W0511: TODOs in code comments are fine.
11
-# W0142: *args and **kwargs are fine.
12
-# W0622: Redefining id is fine.
13
-disable=C0111,W0511,W0142,W0622
8
+disable=
9
+# "F" Fatal errors that prevent further processing
10
+# "I" Informational noise
11
+ locally-disabled,
12
+# "E" Error for important programming issues (likely bugs)
13
+ access-member-before-definition,
14
+ assignment-from-no-return,
15
+ bad-super-call,
16
+ import-error,
17
+ logging-too-few-args,
18
+ method-hidden,
19
+ misplaced-bare-raise,
20
+ no-member,
21
+ no-name-in-module,
22
+ not-an-iterable,
23
+ not-callable,
24
+ raising-non-exception,
25
+ redundant-keyword-arg,
26
+ undefined-all-variable,
27
+ unexpected-keyword-arg,
28
+# "W" Warnings for stylistic problems or minor programming issues
29
+ arguments-differ,
30
+ attribute-defined-outside-init,
31
+ bad-indentation,
32
+ broad-except,
33
+ cell-var-from-loop,
34
+ dangerous-default-value,
35
+ deprecated-method,  # TODO
36
+ exec-used,
37
+ fixme,
38
+ keyword-arg-before-vararg,  # TODO
39
+ logging-not-lazy,
40
+ pointless-string-statement,
41
+ protected-access,
42
+ raising-format-tuple,
43
+ redefined-builtin,
44
+ redefined-outer-name,
45
+ reimported,
46
+ signature-differs,
47
+ super-init-not-called,
48
+ undefined-loop-variable,
49
+ unidiomatic-typecheck,
50
+ unnecessary-pass,
51
+ unused-argument,
52
+ unused-import,
53
+ unused-wildcard-import,
54
+ useless-else-on-loop,
55
+ useless-super-delegation,
56
+ using-constant-test,
57
+ wildcard-import,
58
+# "C" Coding convention violations
59
+ abstract-method,
60
+ anomalous-backslash-in-string,
61
+ bad-builtin,
62
+ bad-continuation,
63
+ bad-mcs-classmethod-argument,
64
+ deprecated-lambda,
65
+ expression-not-assigned,
66
+ global-statement,
67
+ invalid-name,
68
+ len-as-condition,
69
+ line-too-long,
70
+ misplaced-comparison-constant,
71
+ missing-docstring,
72
+ no-method-argument,
73
+ superfluous-parens,
74
+ too-many-lines,
75
+ try-except-raise,
76
+ ungrouped-imports,
77
+ unused-variable,
78
+ wrong-import-order,  # TODO
79
+# "R" Refactor recommendations
80
+ chained-comparison,
81
+ comparison-with-itself,
82
+ consider-using-dict-comprehension,
83
+ consider-using-in,
84
+ consider-using-set-comprehension,
85
+ cyclic-import,  # TODO
86
+ duplicate-code,
87
+ inconsistent-return-statements,  # TODO
88
+ interface-not-implemented,
89
+ no-else-return,
90
+ no-self-use,
91
+ redefined-argument-from-local,
92
+ simplifiable-if-expression,
93
+ simplifiable-if-statement,
94
+ too-many-ancestors,
95
+ too-many-arguments,
96
+ too-many-branches,
97
+ too-many-function-args,
98
+ too-many-instance-attributes,
99
+ too-many-locals,
100
+ too-many-nested-blocks,
101
+ too-many-return-statements,
102
+ too-many-statements,
103
+ trailing-comma-tuple,
104
+ useless-object-inheritance
14 105
 
15 106
 [Basic]
16 107
 # Variable names can be 1 to 31 characters long, with lowercase and underscores
@@ -29,6 +120,10 @@ module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(keystone-[a-z0-9_-]+))$
29 120
 # Don't require docstrings on tests.
30 121
 no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
31 122
 
123
+[Format]
124
+# Maximum number of characters on a single line.
125
+max-line-length=80
126
+
32 127
 [Design]
33 128
 max-public-methods=100
34 129
 min-public-methods=0
@@ -40,3 +135,11 @@ max-args=6
40 135
 # you should avoid to define new builtins when possible.
41 136
 # _ is used by our localization
42 137
 additional-builtins=_
138
+
139
+[typecheck]
140
+# List of module names for which member attributes should not be checked
141
+ignored-modules=six.moves,_MovedItems
142
+
143
+[reports]
144
+# Tells whether to display a full report or only the messages
145
+reports=no

+ 1
- 1
openstack_dashboard/api/nova.py View File

@@ -590,7 +590,7 @@ def server_list_paged(request,
590 590
         search_opts['project_id'] = request.user.tenant_id
591 591
 
592 592
     if search_opts.pop('paginate', False):
593
-        reversed_order = sort_dir is "asc"
593
+        reversed_order = sort_dir == "asc"
594 594
         LOG.debug("Notify received on deleted server: %r",
595 595
                   ('server_deleted' in request.session))
596 596
         deleted = request.session.pop('server_deleted',

+ 2
- 0
test-requirements.txt View File

@@ -9,6 +9,7 @@
9 9
 # Hacking should appear first in case something else depends on pep8
10 10
 hacking>=1.1.0 # Apache-2.0
11 11
 #
12
+astroid==2.1.0;python_version>='3.0' # LGPLv2.1
12 13
 bandit>=1.4.0 # Apache-2.0
13 14
 coverage!=4.4,>=4.0 # Apache-2.0
14 15
 doc8>=0.6.0 # Apache-2.0
@@ -16,6 +17,7 @@ flake8-import-order==0.12 # LGPLv3
16 17
 mock>=2.0.0 # BSD
17 18
 mox3>=0.20.0 # Apache-2.0
18 19
 nodeenv>=0.9.4 # BSD
20
+pylint==2.2.2;python_version>='3.0' # GPLv2
19 21
 selenium>=2.50.1 # Apache-2.0
20 22
 testscenarios>=0.4 # Apache-2.0/BSD
21 23
 testtools>=2.2.0 # MIT

+ 1
- 0
tox.ini View File

@@ -65,6 +65,7 @@ commands =
65 65
   {envpython} {toxinidir}/manage.py extract_messages --verbosity 0 --check-only
66 66
   bash {toxinidir}/tools/find_executables.sh
67 67
   doc8 doc/source releasenotes/source releasenotes/notes
68
+  pylint -j 4 --verbose --rcfile=.pylintrc -f colorized openstack_dashboard openstack_auth horizon
68 69
 
69 70
 [testenv:cover]
70 71
 basepython = python3

Loading…
Cancel
Save