]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix pylint unbalanced-tuple-unpacking warning
authorCedric Brandily <zzelle@gmail.com>
Fri, 16 Jan 2015 23:41:16 +0000 (23:41 +0000)
committerCedric Brandily <zzelle@gmail.com>
Sun, 18 Jan 2015 11:37:43 +0000 (11:37 +0000)
Pylint last version(1.4.1), at least, reports an
unbalanced-tuple-unpacking warning[1] in keepalived[2] module because
self.authentication is defined as an empty tuple in __init__ method and
unpacked in build_config method as if it was a 2-tuple.

self.authentication references an empty tuple (defined in __init__
method) or a 2-tuple (updated in set_authentication method). Such
warning is a false positive because the unpacking is only performed if
self.authentication is not evaluated to false which only appends if
self.authentication is a 2-tuple.

Defining self.authentication as None in __init__ avoids such warning
without disabling unbalanced-tuple-unpacking warning check.

[1]
W:252,12: Possible unbalanced tuple unpacking with sequence defined at
line 153: left side has 2 label(s), right side has 0 value(s)
(unbalanced-tuple-unpacking)

[2] neutron.agent.linux.keepalived

Change-Id: Ifcdf08e574ef44a65c6d121323cbe31d9af2f921
Closes-Bug: #1411865

.pylintrc
neutron/agent/linux/keepalived.py

index e54a281e1f2a2c3eb04f09a151a7c933ed51b4cf..ad9c8211bc8f39083c928d2bfa4cc8740682f591 100644 (file)
--- a/.pylintrc
+++ b/.pylintrc
@@ -50,7 +50,6 @@ disable=
  signature-differs,
  star-args,
  super-init-not-called,
- unbalanced-tuple-unpacking,
  unnecessary-lambda,
  unnecessary-pass,
  unpacking-non-sequence,
index 596ee6e0240b73eb2050ae84fb7de054a0d7775b..bbeb3fe32790d5082cb910bcd16aa9815acfef3f 100644 (file)
@@ -150,7 +150,7 @@ class KeepalivedInstance(object):
         self.track_interfaces = []
         self.vips = []
         self.virtual_routes = []
-        self.authentication = tuple()
+        self.authentication = None
         metadata_cidr = '169.254.169.254/32'
         self.primary_vip_range = get_free_range(
             parent_range='169.254.0.0/16',