diff --git a/.pylintrc b/.pylintrc index 1c942d426..2206810ce 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,12 +1,16 @@ # The format of this file isn't really documented; just use --generate-rcfile -[MASTER] +[MAIN] # Add to the black list. It should be a base name, not a # path. You may set this option multiple times. -# -# Note the 'openstack' below is intended to match only -# neutron.openstack.common. If we ever have another 'openstack' -# dirname, then we'll need to expand the ignore features in pylint :/ -ignore=.git,tests,openstack +ignore=.git,tests + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins=pylint.extensions.no_self_use + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes [MESSAGES CONTROL] # NOTE(gus): This is a long list. A number of these are important and @@ -16,69 +20,63 @@ disable= # "F" Fatal errors that prevent further processing import-error, # "I" Informational noise + c-extension-no-member, locally-disabled, # "E" Error for important programming issues (likely bugs) access-member-before-definition, - bad-super-call, - maybe-no-member, no-member, no-method-argument, no-self-argument, - not-callable, - no-value-for-parameter, - super-on-old-class, - too-few-format-args, + not-an-iterable, + possibly-used-before-assignment, # "W" Warnings for stylistic problems or minor programming issues abstract-method, - anomalous-backslash-in-string, - anomalous-unicode-escape-in-string, arguments-differ, attribute-defined-outside-init, - bad-builtin, - bad-indentation, broad-except, - dangerous-default-value, - deprecated-lambda, expression-not-assigned, fixme, global-statement, - global-variable-not-assigned, - logging-not-lazy, - no-init, non-parent-init-called, - pointless-string-statement, + not-callable, protected-access, redefined-builtin, redefined-outer-name, - redefine-in-handler, signature-differs, - star-args, super-init-not-called, - unnecessary-lambda, - unnecessary-pass, unpacking-non-sequence, - unreachable, unused-argument, unused-import, unused-variable, -# TODO(dougwig) - disable nonstandard-exception while we have neutron_lib shims - nonstandard-exception, + useless-super-delegation, + unnecessary-pass, + raise-missing-from, + arguments-renamed, + broad-exception-raised, + unspecified-encoding, + redundant-u-string-prefix, + unused-private-member, # "C" Coding convention violations - bad-continuation, + consider-iterating-dictionary, + consider-using-enumerate, invalid-name, + len-as-condition, missing-docstring, - old-style-class, + singleton-comparison, superfluous-parens, + ungrouped-imports, + wrong-import-order, + consider-using-f-string, + consider-using-dict-items, # "R" Refactor recommendations - abstract-class-little-used, - abstract-class-not-used, - consider-using-set-comprehension, + consider-merging-isinstance, + consider-using-ternary, duplicate-code, inconsistent-return-statements, - interface-not-implemented, - no-else-raise, no-else-return, no-self-use, + redefined-argument-from-local, + simplifiable-if-statement, too-few-public-methods, too-many-ancestors, too-many-arguments, @@ -86,10 +84,14 @@ disable= too-many-instance-attributes, too-many-lines, too-many-locals, + too-many-nested-blocks, too-many-public-methods, too-many-return-statements, too-many-statements, - useless-object-inheritance + consider-using-set-comprehension, + useless-object-inheritance, + super-with-arguments, + use-dict-literal [BASIC] # Variable names can be 1 to 31 characters long, with lowercase and underscores @@ -99,7 +101,7 @@ variable-rgx=[a-z_][a-z0-9_]{0,30}$ argument-rgx=[a-z_][a-z0-9_]{1,30}$ # Method names should be at least 3 characters long -# and be lowecased with underscores +# and be lowercased with underscores method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$ # Module names matching neutron-* are ok (files in bin/) @@ -119,18 +121,22 @@ max-line-length=79 additional-builtins=_ [CLASSES] -# List of interface methods to ignore, separated by a comma. -ignore-iface-methods= +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls [IMPORTS] # Deprecated modules which should not be used, separated by a comma deprecated-modules= -# should use openstack.common.jsonutils - json +# should use oslo_serialization.jsonutils + json, + six [TYPECHECK] # List of module names for which member attributes should not be checked -ignored-modules=six.moves,_MovedItems +ignored-modules=_MovedItems [REPORTS] # Tells whether to display a full report or only the messages diff --git a/neutron_vpnaas/db/vpn/vpn_db.py b/neutron_vpnaas/db/vpn/vpn_db.py index f7f3257a5..586ca5e9f 100644 --- a/neutron_vpnaas/db/vpn/vpn_db.py +++ b/neutron_vpnaas/db/vpn/vpn_db.py @@ -72,14 +72,14 @@ class VPNPluginDb(vpnaas.VPNPluginBase, raise vpn_exception.IPsecSiteConnectionNotFound( ipsec_site_conn_id=v_id ) - elif issubclass(model, vpn_models.IKEPolicy): + if issubclass(model, vpn_models.IKEPolicy): raise vpn_exception.IKEPolicyNotFound(ikepolicy_id=v_id) - elif issubclass(model, vpn_models.IPsecPolicy): + if issubclass(model, vpn_models.IPsecPolicy): raise vpn_exception.IPsecPolicyNotFound( ipsecpolicy_id=v_id) - elif issubclass(model, vpn_models.VPNService): + if issubclass(model, vpn_models.VPNService): raise vpn_exception.VPNServiceNotFound(vpnservice_id=v_id) - elif issubclass(model, vpn_models.VPNEndpointGroup): + if issubclass(model, vpn_models.VPNEndpointGroup): raise vpn_exception.VPNEndpointGroupNotFound( endpoint_group_id=v_id) ctx.reraise = True diff --git a/neutron_vpnaas/services/vpn/device_drivers/ipsec.py b/neutron_vpnaas/services/vpn/device_drivers/ipsec.py index 7ffcaac71..849c2c0fc 100644 --- a/neutron_vpnaas/services/vpn/device_drivers/ipsec.py +++ b/neutron_vpnaas/services/vpn/device_drivers/ipsec.py @@ -329,8 +329,8 @@ class BaseSwanProcess(object, metaclass=abc.ABCMeta): # Disable the process if a vpnservice is disabled or it has no # enabled IPSec site connections. vpnservice_has_active_ipsec_site_conns = any( - [ipsec_site_conn['admin_state_up'] - for ipsec_site_conn in self.vpnservice['ipsec_site_connections']]) + ipsec_site_conn['admin_state_up'] + for ipsec_site_conn in self.vpnservice['ipsec_site_connections']) if (not self.vpnservice['admin_state_up'] or not vpnservice_has_active_ipsec_site_conns): self.disable() diff --git a/neutron_vpnaas/tests/functional/common/test_migrations_sync.py b/neutron_vpnaas/tests/functional/common/test_migrations_sync.py index a4086e2a3..09c31a921 100644 --- a/neutron_vpnaas/tests/functional/common/test_migrations_sync.py +++ b/neutron_vpnaas/tests/functional/common/test_migrations_sync.py @@ -28,7 +28,10 @@ VERSION_TABLE = 'alembic_version_vpnaas' class _TestModelsMigrationsVPNAAS(test_migrations._TestModelsMigrations): def db_sync(self, engine): - cfg.CONF.set_override('connection', engine.url, group='database') + cfg.CONF.set_override( + 'connection', + engine.url.render_as_string(hide_password=False), + group='database') for conf in migration.get_alembic_configs(): self.alembic_config = conf self.alembic_config.neutron_config = cfg.CONF diff --git a/tox.ini b/tox.ini index 3e939b52d..1bd3ebe18 100644 --- a/tox.ini +++ b/tox.ini @@ -74,7 +74,7 @@ deps = {[testenv]deps} hacking>=4.0.0,<4.1 # Apache-2.0 flake8-import-order==0.18.1 # LGPLv3 - pylint==2.5.3 # GPLv2 + pylint==3.2.0 # GPLv2 isort==4.3.21 # MIT commands = flake8