Fix pylint unbalanced-tuple-unpacking warning

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
This commit is contained in:
Cedric Brandily 2015-01-16 23:41:16 +00:00
parent e749d3c4ba
commit c9974b9269
2 changed files with 1 additions and 2 deletions

View File

@ -50,7 +50,6 @@ disable=
signature-differs, signature-differs,
star-args, star-args,
super-init-not-called, super-init-not-called,
unbalanced-tuple-unpacking,
unnecessary-lambda, unnecessary-lambda,
unnecessary-pass, unnecessary-pass,
unpacking-non-sequence, unpacking-non-sequence,

View File

@ -150,7 +150,7 @@ class KeepalivedInstance(object):
self.track_interfaces = [] self.track_interfaces = []
self.vips = [] self.vips = []
self.virtual_routes = [] self.virtual_routes = []
self.authentication = tuple() self.authentication = None
metadata_cidr = '169.254.169.254/32' metadata_cidr = '169.254.169.254/32'
self.primary_vip_range = get_free_range( self.primary_vip_range = get_free_range(
parent_range='169.254.0.0/16', parent_range='169.254.0.0/16',