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
This commit is contained in:
Akihiro Motoki 2018-10-07 08:12:36 +09:00
parent f02e7c5ade
commit 220b1346bd
4 changed files with 114 additions and 8 deletions

117
.pylintrc
View File

@ -2,15 +2,106 @@
[MASTER]
# Add <file or directory> to the black list. It should be a base name, not a
# path. You may set this option multiple times.
ignore=test
ignore=test,tests,tests.py,local_settings.py
[Messages Control]
# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future
# C0111: Don't require docstrings on every method
# W0511: TODOs in code comments are fine.
# W0142: *args and **kwargs are fine.
# W0622: Redefining id is fine.
disable=C0111,W0511,W0142,W0622
disable=
# "F" Fatal errors that prevent further processing
# "I" Informational noise
locally-disabled,
# "E" Error for important programming issues (likely bugs)
access-member-before-definition,
assignment-from-no-return,
bad-super-call,
import-error,
logging-too-few-args,
method-hidden,
misplaced-bare-raise,
no-member,
no-name-in-module,
not-an-iterable,
not-callable,
raising-non-exception,
redundant-keyword-arg,
undefined-all-variable,
unexpected-keyword-arg,
# "W" Warnings for stylistic problems or minor programming issues
arguments-differ,
attribute-defined-outside-init,
bad-indentation,
broad-except,
cell-var-from-loop,
dangerous-default-value,
deprecated-method, # TODO
exec-used,
fixme,
keyword-arg-before-vararg, # TODO
logging-not-lazy,
pointless-string-statement,
protected-access,
raising-format-tuple,
redefined-builtin,
redefined-outer-name,
reimported,
signature-differs,
super-init-not-called,
undefined-loop-variable,
unidiomatic-typecheck,
unnecessary-pass,
unused-argument,
unused-import,
unused-wildcard-import,
useless-else-on-loop,
useless-super-delegation,
using-constant-test,
wildcard-import,
# "C" Coding convention violations
abstract-method,
anomalous-backslash-in-string,
bad-builtin,
bad-continuation,
bad-mcs-classmethod-argument,
deprecated-lambda,
expression-not-assigned,
global-statement,
invalid-name,
len-as-condition,
line-too-long,
misplaced-comparison-constant,
missing-docstring,
no-method-argument,
superfluous-parens,
too-many-lines,
try-except-raise,
ungrouped-imports,
unused-variable,
wrong-import-order, # TODO
# "R" Refactor recommendations
chained-comparison,
comparison-with-itself,
consider-using-dict-comprehension,
consider-using-in,
consider-using-set-comprehension,
cyclic-import, # TODO
duplicate-code,
inconsistent-return-statements, # TODO
interface-not-implemented,
no-else-return,
no-self-use,
redefined-argument-from-local,
simplifiable-if-expression,
simplifiable-if-statement,
too-many-ancestors,
too-many-arguments,
too-many-branches,
too-many-function-args,
too-many-instance-attributes,
too-many-locals,
too-many-nested-blocks,
too-many-return-statements,
too-many-statements,
trailing-comma-tuple,
useless-object-inheritance
[Basic]
# 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_-]+))$
# Don't require docstrings on tests.
no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
[Format]
# Maximum number of characters on a single line.
max-line-length=80
[Design]
max-public-methods=100
min-public-methods=0
@ -40,3 +135,11 @@ max-args=6
# you should avoid to define new builtins when possible.
# _ is used by our localization
additional-builtins=_
[typecheck]
# List of module names for which member attributes should not be checked
ignored-modules=six.moves,_MovedItems
[reports]
# Tells whether to display a full report or only the messages
reports=no

View File

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

View File

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

View File

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