On Wednesday 24 March 2010 05:02:09 Donovan Lee Wanhoy wrote:
> Well i forgot to attach the file. Here it is.
0/ hm, I think, you should run at least all pylint's test before proposing
a patch.
File "/home/emile/src/pylint/checkers/base.py", line 437, in
visit_function
for ancestor in node.parent.frame().ancestors():
AttributeError: 'Module' object has no attribute 'ancestors'
1/ A function node can be on module level; hence you should check if
node.parent is a Class node
2/ if overrriden = True, do a break
3/ our conventions :
- avoid trailing white spaces
- no error tests are usually called func_noerror*
and have no corresponding error message file
(example attached)
--
Emile Anclin <[email protected]>
http://www.logilab.fr/ http://www.logilab.org/
Informatique scientifique & et gestion de connaissances
diff -r b0aab39f8f1f -r 6e44028ec85b checkers/base.py
--- a/checkers/base.py Tue Mar 23 18:49:08 2010 +0100
+++ b/checkers/base.py Wed Mar 24 10:19:50 2010 +0100
@@ -432,7 +432,14 @@
self._check_name(f_type, node.name, node)
# docstring
if self.config.no_docstring_rgx.match(node.name) is None:
- self._check_docstring(f_type, node)
+ overridden = False
+ # check if node is from a method overridden by its ancestor
+ for ancestor in node.parent.frame().ancestors():
+ if node.name in ancestor and \
+ isinstance(ancestor[node.name], astng.Function):
+ overridden = True
+ if not overridden:
+ self._check_docstring(f_type, node)
# check default arguments'value
self._check_defaults(node)
# check arguments name
diff -r b0aab39f8f1f -r 6e44028ec85b test/input/func_noerror_no_docstring.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/input/func_noerror_no_docstring.py Wed Mar 24 10:19:50 2010 +0100
@@ -0,0 +1,36 @@
+''' Test for inheritence '''
+
+class AAAA:
+ ''' class AAAA '''
+
+ def __init__(self):
+ pass
+
+ def method1(self):
+ ''' method 1 '''
+ print self
+
+ def method3(self):
+ ''' method 3 '''
+ print self
+
+class BBBB(AAAA):
+ ''' class BBBB '''
+
+ def __init__(self):
+ AAAA.__init__(self)
+
+ # should ignore docstring calling from class AAAA
+ def method1(self):
+ AAAA.method1(self)
+
+class CCCC(BBBB):
+ ''' class CCCC '''
+
+ def __init__(self):
+ BBBB.__init__(self)
+
+ # should ignore docstring since CCCC is inherited from BBBB which is
+ # inherited from AAAA containing method3
+ def method3(self):
+ AAAA.method3(self)
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects