diff --git a/lib/backend.py b/lib/backend.py index 3aac2500de60e0783c67136e78f65501f3047c3b..2961371fb706754972dd899fdc1eb33d85dd7f9c 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -26,6 +26,12 @@ """ +# pylint: disable-msg=E1103 + +# E1103: %s %r has no %r member (but some types could not be +# inferred), because the _TryOSFromDisk returns either (True, os_obj) +# or (False, "string") which confuses pylint + import os import os.path diff --git a/lib/confd/client.py b/lib/confd/client.py index db9a71c815664e0cb8e54893e81c61cab1469101..674a2ca394b85b3027c9e82e54da3e32653ccede 100644 --- a/lib/confd/client.py +++ b/lib/confd/client.py @@ -45,6 +45,11 @@ confirming what you already got. """ +# pylint: disable-msg=E0203 + +# E0203: Access to member %r before its definition, since we use +# objects.py which doesn't explicitely initialise its members + import socket import time import random @@ -400,4 +405,3 @@ class ConfdFilterCallback: if not filter_upcall: self._callback(up) - diff --git a/lib/http/client.py b/lib/http/client.py index 717581f6f4295dfdab325a6bae15780d3793c4cc..5b76cf3c3cc2d54e3a6e06a8c9d9f9ba4e40802a 100644 --- a/lib/http/client.py +++ b/lib/http/client.py @@ -22,6 +22,13 @@ """ +# pylint: disable-msg=E1103 + +# # E1103: %s %r has no %r member (but some types could not be +# inferred), since _socketobject could be ssl or not and pylint +# doesn't parse that + + import os import select import socket diff --git a/lib/jqueue.py b/lib/jqueue.py index 73d6a0ed571e34ce841a6cd52178a72f28df2455..9f1d5bec0426ffabd2cb471cda48cc60758fef26 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -540,33 +540,37 @@ class _JobQueueWorkerPool(workerpool.WorkerPool): self.queue = queue -class JobQueue(object): - """Queue used to manage the jobs. +def _RequireOpenQueue(fn): + """Decorator for "public" functions. - @cvar _RE_JOB_FILE: regex matching the valid job file names + This function should be used for all 'public' functions. That is, + functions usually called from other classes. Note that this should + be applied only to methods (not plain functions), since it expects + that the decorated function is called with a first argument that has + a '_queue_lock' argument. - """ - _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) + @warning: Use this decorator only after utils.LockedMethod! - def _RequireOpenQueue(fn): - """Decorator for "public" functions. + Example:: + @utils.LockedMethod + @_RequireOpenQueue + def Example(self): + pass - This function should be used for all 'public' functions. That is, - functions usually called from other classes. + """ + def wrapper(self, *args, **kwargs): + assert self._queue_lock is not None, "Queue should be open" + return fn(self, *args, **kwargs) + return wrapper - @warning: Use this decorator only after utils.LockedMethod! - Example:: - @utils.LockedMethod - @_RequireOpenQueue - def Example(self): - pass +class JobQueue(object): + """Queue used to manage the jobs. - """ - def wrapper(self, *args, **kwargs): - assert self._queue_lock is not None, "Queue should be open" - return fn(self, *args, **kwargs) - return wrapper + @cvar _RE_JOB_FILE: regex matching the valid job file names + + """ + _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) def __init__(self, context): """Constructor for JobQueue. diff --git a/lib/objects.py b/lib/objects.py index 06bc7e0298e41451b7682eb43cfd952afb6ff76b..2f3b4f6ee85859e8ae5f35fcff5abf35fe3183c4 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -26,6 +26,11 @@ pass to and from external parties. """ +# pylint: disable-msg=E0203 + +# E0203: Access to member %r before its definition, since we use +# objects.py which doesn't explicitely initialise its members + import ConfigParser import re diff --git a/lib/storage.py b/lib/storage.py index 7f731009930d04023e7429ebbf899dec4c53ad97..b4b303af67d495702ceb56ebc58ff7c02692da50 100644 --- a/lib/storage.py +++ b/lib/storage.py @@ -328,6 +328,7 @@ class LvmPvStorage(_LvmBase): """LVM Physical Volume storage unit. """ + @staticmethod def _GetAllocatable(attr): if attr: return (attr[0] == "a") diff --git a/lib/utils.py b/lib/utils.py index ec7fec83844c86d6d99ef7523349518cc22268be..65ef2c3417110a67715bef98fc805ef304812653 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -2413,12 +2413,12 @@ class FieldSet(object): @type field: str @param field: the string to match - @return: either False or a regular expression match object + @return: either None or a regular expression match object """ for m in itertools.ifilter(None, (val.match(field) for val in self.items)): return m - return False + return None def NonMatching(self, items): """Returns the list of fields not matching the current set