Hi, Here is my new patch. Made the changes that you (Emile) requested. Ran all the pylint tests and.called the test file func_noerror_no_docstring_warning.
Donovan Lee Wanhoy On Wed, Mar 24, 2010 at 5:28 AM, Emile Anclin <emile.anc...@logilab.fr>wrote: > 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 <emile.anc...@logilab.fr> > http://www.logilab.fr/ http://www.logilab.org/ > Informatique scientifique & et gestion de connaissances >
diff -r f5f084e5267a checkers/base.py --- a/checkers/base.py Thu Mar 04 12:12:32 2010 +0100 +++ b/checkers/base.py Fri Mar 26 12:25:25 2010 -0400 @@ -428,7 +428,18 @@ 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) + if isinstance(node.parent, astng.Class): + 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 + break + if not overridden: + self._check_docstring(f_type, node) + else: + self._check_docstring(f_type, node) # check default arguments'value self._check_defaults(node) # check arguments name diff -r f5f084e5267a test/input/func_noerror_no_warning_docstring.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/input/func_noerror_no_warning_docstring.py Fri Mar 26 12:25:25 2010 -0400 @@ -0,0 +1,38 @@ +''' Test for inheritence ''' + +__revision__ = 1 + +class AAAA: + ''' class AAAA ''' + + def __init__(self): + pass + + def method1(self): + ''' method 1 ''' + print self + + def method2(self): + ''' method 2 ''' + 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 method2(self): + AAAA.method2(self)
_______________________________________________ Python-Projects mailing list Python-Projects@lists.logilab.org http://lists.logilab.org/mailman/listinfo/python-projects