Start enforcing additional pylint checks

There were a number of checks disabled in .pylintrc
that can just be removed. There were a few others
that required some small code changes:

    expression-not-assigned
    consider-merging-isinstance
    consider-using-ternary

TrivialFix

Change-Id: I5b4f449a0d7f7653ec0349f0806288c4b21d44f9
This commit is contained in:
Brian Haley 2024-11-05 18:06:53 -05:00
parent 822edc31c8
commit a6392b56fd
4 changed files with 9 additions and 18 deletions

View File

@ -20,8 +20,6 @@ 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,
no-member,
@ -34,7 +32,6 @@ disable=
arguments-differ,
attribute-defined-outside-init,
broad-except,
expression-not-assigned,
fixme,
global-statement,
not-callable,
@ -52,13 +49,11 @@ disable=
arguments-renamed,
broad-exception-raised,
unspecified-encoding,
redundant-u-string-prefix,
unused-private-member,
# "C" Coding convention violations
consider-iterating-dictionary,
consider-using-enumerate,
invalid-name,
len-as-condition,
missing-docstring,
singleton-comparison,
superfluous-parens,
@ -67,14 +62,11 @@ disable=
consider-using-f-string,
consider-using-dict-items,
# "R" Refactor recommendations
consider-merging-isinstance,
consider-using-ternary,
duplicate-code,
inconsistent-return-statements,
no-else-return,
no-self-use,
redefined-argument-from-local,
simplifiable-if-statement,
too-few-public-methods,
too-many-ancestors,
too-many-arguments,
@ -86,7 +78,6 @@ disable=
too-many-public-methods,
too-many-return-statements,
too-many-statements,
consider-using-set-comprehension,
use-dict-literal
[BASIC]

View File

@ -149,10 +149,7 @@ class HaRouter(router.RouterInfo):
"""this method is normally called before the ha_router object is fully
initialized
"""
if self.router.get('_ha_state') == 'active':
return True
else:
return False
return bool(self.router.get('_ha_state') == 'active')
def initialize(self, process_monitor):
ha_port = self.router.get(n_consts.HA_INTERFACE_KEY)

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
import datetime
import secrets
import time
@ -501,9 +502,10 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
network_ids = {s.network_id for s in subnets}
# pre-compute net-id per segments.
netsegs = {}
[netsegs.setdefault(s['network_id'], []).append(s)
for s in segments if 'network_id' in s]
netsegs = collections.defaultdict(list)
for s in segments:
if 'network_id' in s:
netsegs[s['network_id']].append(s)
for network_id in network_ids:
for segment in netsegs.get(network_id, []):
self._schedule_network(

View File

@ -227,8 +227,9 @@ class NeutronObject(obj_base.VersionedObject,
@classmethod
def is_object_field(cls, field):
return (isinstance(cls.fields[field], obj_fields.ListOfObjectsField) or
isinstance(cls.fields[field], obj_fields.ObjectField))
return isinstance(
cls.fields[field],
(obj_fields.ListOfObjectsField, obj_fields.ObjectField))
@classmethod
def obj_class_from_name(cls, objname, objver):