[Biopython-dev] Running pylint over Biopython

Peter biopython at maubp.freeserve.co.uk
Tue Feb 23 17:43:31 UTC 2010


Hi all,

Those following @Biopython on twitter or subscribed to the github RSS
feed for our repository will know this already, but I've been using
pylint today to spot some errors in Biopython.
http://www.logilab.org/project/pylint

This was prompted by Eric trying this on Bio.PDB for Bug 3013 and
finding some issues - thank Eric, this was a valuable suggestion.

With its default settings pylint is very very noisy, and in particular
doesn't like our naming conventions. However, with the following
command line you can focus in on the important stuff:

pylint --disable-msg-cat=CRW --include-ids=y
--disable-msg=E1101,E1103,E0102 -r n Bio BioSQL

Note that instead of module names, you can give filenames (e.g. *.py).
What that does is disable several categories of message (conventions,
possible refactorings, warnings) leaving just errors and fatal
messages. I turned on the message identifiers so that I have something
useful to stick into Google if need be, or to add to the ignore list
(currently three cases which looked like false positives). Then I turn
off the detailed report.

[Tip - don't run this from the Biopython source directory as then
importing our C code modules will fail]

As you will be able to tell from the recent flurry of git commits,
this highlighted some simple errors like missing imports or typos in
variable names.


Tiago, could you have a look at these possible problems in Bio.PopGen:

************* Module Bio.PopGen.Async
E0602: 78:Async.get_result: Undefined variable 'done'
E0602: 79:Async.get_result: Undefined variable 'done'
************* Module Bio.PopGen.GenePop
E0602:160:Record.split_in_pops: Undefined variable 'GenePop'
E0602:177:Record.split_in_loci: Undefined variable 'GenePop'
************* Module Bio.PopGen.GenePop.Controller
E0602: 41:_read_allele_freq_table: Undefined variable 'self'
E0602:133:_hw_func: Undefined variable 'self'
E0602:393:GenePopController.test_pop_hw_prob: Undefined variable 'ext'
E0602:458:GenePopController.test_ld.ld_pop_func: Undefined variable
'currrent_pop'
************* Module Bio.PopGen.SimCoal.Cache
E0602: 79:SimCoalCache.getSimulation: Undefined variable 'Config'
E0602: 88: Undefined variable 'Cache'
************* Module Bio.PopGen.SimCoal.Controller
E0602: 47:SimCoalController.run_simcoal: Undefined variable 'Config'


Eric, I don't have all the dependencies installed by pylint does
appear to dislike a few things in Bio.Phylo on the trunk:

************* Module Bio.Phylo.BaseTree
E0203:521:TreeMixin.prune: Access to member 'root' before its
definition line 531
E0203:527:TreeMixin.prune: Access to member 'root' before its
definition line 531
E0202:672:Subtree.root: An attribute inherited from TreeMixin hide this method
************* Module Bio.Phylo.PhyloXML
E1120:182:Phylogeny.get_alignment: No value passed for parameter
'follow_attrs' in function call


One thing this exercise has shown is that we still need to do some
work on the unit test coverage.

Regards

Peter



More information about the Biopython-dev mailing list