from
Pierre Rouleau <prouleau001 at sympatico dot ca>
subject
[Python-projects] Pylint 0.6.4 does not report missing argument to
__init__
date
Bonjour à tous!2005/05/22 18:25
I have found a case where pylint does not report a problem in Python code.
In the following test script, I define a Shared class where
Shared.__init__() requires 1 argument. The test instantiates one
instance of Shared but does not specify any value.
Pychecker properly reports the missing argument but pylint does not.
Here's the code:
#test_shared.py:
#[------------------------------
import threading
__author__ = "Pierre Rouleau"
__version__ = "$Revision: 1.1 $".split()[1]
__category__ = "module, Pylint test"
class Shared(object):
""" Shared value inside critical section.
A Shared object has a single read/write attribute: ``value``.
Accesses to the value controlled by the class are serialized, allowing
read/write data sharing across multiple threads.
"""
def __init__(self, initial_value): # Create instance
"Create and initialize locked value"
self.__value = initial_value
self.__lock = threading.Lock()
def get_value(self):
"protected read access to the value"
self.__lock.acquire()
the_value = self.__value
self.__lock.release()
return the_value
def set_value(self, new_value):
"protected write access to the value"
self.__lock.acquire()
self.__value = new_value
self.__lock.release()
value = property(fget=get_value, fset=set_value, doc='Multi-thread
safe variable access')
if __name__ == "__main__":
someValue = Shared()
#------------------------------]
Now, here's the report from Pychecker and the beginning of Pylint report:
# [-------------------------------
--- Pychecker report ---
Processing test_shared...
Warnings...
test_shared.py:5: Variable (__category__) not used
test_shared.py:41: Invalid arguments to (__init__), got 0, expected 1
--- Epydoc documentation check report ---
Importing 1 modules.
[.]
Building API documentation for 1 modules.
[.]
Performing completeness checks...
python.test_pylint.test_shared..............................No descr
--- Running PyLint check ---
Pylint control file: c:\dev\python\pylintrc.txt
C:\dev\python\test_pylint\test_shared.py:0: [W0131] Missing docstring
Report
======
20 statements analysed.
#--------------------------------]
--
Pierre Rouleau
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects
