aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/OptionString.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-12-04 13:24:07 +0100
committerPeter Mikus <pmikus@cisco.com>2019-12-05 07:03:57 +0000
commit063abf35e81deaf749ebbcfee339fbd1d9e89412 (patch)
treec932eac04f162c46b0f3c38db10105b945a617cb /resources/libraries/python/OptionString.py
parent6221f1b96d2a167c6db74ff26cd7ec7906ae9486 (diff)
Deal with some "pylint: disable=" comments
+ When possible, fix the violation. + Else, add a comment: + An explanation (if not already present) and keep disable. + A TODO (if not already present) and remove the disable. - This makes tox job report more pylint violations, but any such violation is fixable and should be fixed. - Although some need to be fixed in VPP, such as enum item long names. Change-Id: I48604b5eda070083d79dff1439620dbd9e798e1f Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/OptionString.py')
-rw-r--r--resources/libraries/python/OptionString.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/resources/libraries/python/OptionString.py b/resources/libraries/python/OptionString.py
index 9a30d37b9a..bdb5ee2b4c 100644
--- a/resources/libraries/python/OptionString.py
+++ b/resources/libraries/python/OptionString.py
@@ -92,12 +92,17 @@ class OptionString:
self.parts.extend(other.parts)
return self
- def _check_and_add(self, part, prefixed):
+ def check_and_add(self, part, prefixed):
"""Convert to string, strip, conditionally add prefixed if non-empty.
Value of None is converted to empty string.
Emptiness is tested before adding prefix.
+ This could be a protected method (name starting with underscore),
+ but then pylint does not understand add_equals and add_with_value
+ are allowed to call this on the temp instance.
+ TODO: Is there a way to make pylint understand?
+
:param part: Unchecked part to add to list of parts.
:param prefixed: Whether to add prefix when adding.
:type part: object
@@ -123,7 +128,7 @@ class OptionString:
:returns: Self, to enable method chaining.
:rtype: OptionString
"""
- self._check_and_add(parameter, prefixed=True)
+ self.check_and_add(parameter, prefixed=True)
return self
def add_if(self, parameter, condition):
@@ -160,11 +165,8 @@ class OptionString:
:rtype: OptionString
"""
temp = OptionString(prefix=self.prefix)
- # TODO: Is pylint really that ignorant?
- # How could it not understand temp is of type of this class?
- # pylint: disable=protected-access
- if temp._check_and_add(parameter, prefixed=True):
- if temp._check_and_add(value, prefixed=False):
+ if temp.check_and_add(parameter, prefixed=True):
+ if temp.check_and_add(value, prefixed=False):
self.extend(temp)
return self
@@ -183,9 +185,8 @@ class OptionString:
:rtype: OptionString
"""
temp = OptionString(prefix=self.prefix)
- # pylint: disable=protected-access
- if temp._check_and_add(parameter, prefixed=True):
- if temp._check_and_add(value, prefixed=False):
+ if temp.check_and_add(parameter, prefixed=True):
+ if temp.check_and_add(value, prefixed=False):
self.parts.append(u"=".join(temp.parts))
return self