summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Motoki <amotoki@gmail.com>2018-10-07 08:12:36 +0900
committerAkihiro Motoki <amotoki@gmail.com>2019-01-12 22:41:20 +0900
commit220b1346bdfe88d47adb475f48f4a4e96c60560e (patch)
tree4ca559d214a6f2f4c0ab1980ee7e337b3eb5a9f4
parentf02e7c5aded59b06d42a70d22db8fe1c0e8d07b0 (diff)
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
Notes
Notes (review): Code-Review+2: Ivan Kolodyazhny <e0ne@e0ne.info> Workflow+1: Ivan Kolodyazhny <e0ne@e0ne.info> Code-Review+1: Yongjun Bai <baiyj666@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 14 Jan 2019 12:47:49 +0000 Reviewed-on: https://review.openstack.org/623652 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--.pylintrc117
-rw-r--r--openstack_dashboard/api/nova.py2
-rw-r--r--test-requirements.txt2
-rw-r--r--tox.ini1
4 files changed, 114 insertions, 8 deletions
diff --git a/.pylintrc b/.pylintrc
index 64f5caf..afa5fe2 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -2,15 +2,106 @@
2[MASTER] 2[MASTER]
3# Add <file or directory> to the black list. It should be a base name, not a 3# Add <file or directory> to the black list. It should be a base name, not a
4# path. You may set this option multiple times. 4# path. You may set this option multiple times.
5ignore=test 5ignore=test,tests,tests.py,local_settings.py
6 6
7[Messages Control] 7[Messages Control]
8# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future 8disable=
9# C0111: Don't require docstrings on every method 9# "F" Fatal errors that prevent further processing
10# W0511: TODOs in code comments are fine. 10# "I" Informational noise
11# W0142: *args and **kwargs are fine. 11 locally-disabled,
12# W0622: Redefining id is fine. 12# "E" Error for important programming issues (likely bugs)
13disable=C0111,W0511,W0142,W0622 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[Basic] 106[Basic]
16# Variable names can be 1 to 31 characters long, with lowercase and underscores 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# Don't require docstrings on tests. 120# Don't require docstrings on tests.
30no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$ 121no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
31 122
123[Format]
124# Maximum number of characters on a single line.
125max-line-length=80
126
32[Design] 127[Design]
33max-public-methods=100 128max-public-methods=100
34min-public-methods=0 129min-public-methods=0
@@ -40,3 +135,11 @@ max-args=6
40# you should avoid to define new builtins when possible. 135# you should avoid to define new builtins when possible.
41# _ is used by our localization 136# _ is used by our localization
42additional-builtins=_ 137additional-builtins=_
138
139[typecheck]
140# List of module names for which member attributes should not be checked
141ignored-modules=six.moves,_MovedItems
142
143[reports]
144# Tells whether to display a full report or only the messages
145reports=no
diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py
index 0ee17bf..7183234 100644
--- a/openstack_dashboard/api/nova.py
+++ b/openstack_dashboard/api/nova.py
@@ -590,7 +590,7 @@ def server_list_paged(request,
590 search_opts['project_id'] = request.user.tenant_id 590 search_opts['project_id'] = request.user.tenant_id
591 591
592 if search_opts.pop('paginate', False): 592 if search_opts.pop('paginate', False):
593 reversed_order = sort_dir is "asc" 593 reversed_order = sort_dir == "asc"
594 LOG.debug("Notify received on deleted server: %r", 594 LOG.debug("Notify received on deleted server: %r",
595 ('server_deleted' in request.session)) 595 ('server_deleted' in request.session))
596 deleted = request.session.pop('server_deleted', 596 deleted = request.session.pop('server_deleted',
diff --git a/test-requirements.txt b/test-requirements.txt
index 09503f7..098d1d3 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -9,6 +9,7 @@
9# Hacking should appear first in case something else depends on pep8 9# Hacking should appear first in case something else depends on pep8
10hacking>=1.1.0 # Apache-2.0 10hacking>=1.1.0 # Apache-2.0
11# 11#
12astroid==2.1.0;python_version>='3.0' # LGPLv2.1
12bandit>=1.4.0 # Apache-2.0 13bandit>=1.4.0 # Apache-2.0
13coverage!=4.4,>=4.0 # Apache-2.0 14coverage!=4.4,>=4.0 # Apache-2.0
14doc8>=0.6.0 # Apache-2.0 15doc8>=0.6.0 # Apache-2.0
@@ -16,6 +17,7 @@ flake8-import-order==0.12 # LGPLv3
16mock>=2.0.0 # BSD 17mock>=2.0.0 # BSD
17mox3>=0.20.0 # Apache-2.0 18mox3>=0.20.0 # Apache-2.0
18nodeenv>=0.9.4 # BSD 19nodeenv>=0.9.4 # BSD
20pylint==2.2.2;python_version>='3.0' # GPLv2
19selenium>=2.50.1 # Apache-2.0 21selenium>=2.50.1 # Apache-2.0
20testscenarios>=0.4 # Apache-2.0/BSD 22testscenarios>=0.4 # Apache-2.0/BSD
21testtools>=2.2.0 # MIT 23testtools>=2.2.0 # MIT
diff --git a/tox.ini b/tox.ini
index c783dd2..0443d10 100644
--- a/tox.ini
+++ b/tox.ini
@@ -65,6 +65,7 @@ commands =
65 {envpython} {toxinidir}/manage.py extract_messages --verbosity 0 --check-only 65 {envpython} {toxinidir}/manage.py extract_messages --verbosity 0 --check-only
66 bash {toxinidir}/tools/find_executables.sh 66 bash {toxinidir}/tools/find_executables.sh
67 doc8 doc/source releasenotes/source releasenotes/notes 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[testenv:cover] 70[testenv:cover]
70basepython = python3 71basepython = python3