[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Standardizing python code using pylint

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Fri, 18 Dec 2009 09:15:15 +0000

Bhuvaneswaran A wrote:
> ping? Any comments on this proposal?
>
> On Sun, 2009-12-06 at 22:29 +0530, Bhuvaneswaran A wrote:
> > As discussed in this email thread [1], I've come up with the pylint
> > rules for standardizing the python code throughout the repository.
> >
> > Few of rules that would be of crowd's interest are as follows:
> >
> > * Regex for functions: [a-z_][a-z0-9_]{2,30}$
> > * Regex for methods: [a-z_][a-z0-9_]{2,30}$
> > * Regex for arguments: [a-z_][a-z0-9_]{2,30}$
> > * Regex for variables: [a-z_][a-z0-9_]{2,30}$

We need to increase the maximum length. (I see in the RC file that there
are several other types of names, and that capital letters are allowed
in class names and constants, at least.)

> > * Maximum no of arguments: 5
> > * Maximum no of locals: 15
> > * Maximum return statement in a function/method: 6
> > * Maxium statements in function/method: 50
> > * Minimum public method: 2
> > * Maximum public method: 20
> > * Deprecated methods: regsub,string,TERMIOS,Bastion,rexec
> > * Maximum module lines: 1000

All of the above sound like heuristics for giving an overall idea of
"comprehensibility": I'm sure there is lots of code outside these
parameters that we are very happy with. (I hope violations are reported
in the "convention" category rather than "warning", and certainly not
"error".)

Looking in the RC file... aren't most of these disabled?

disable-msg=C0103,C0111,C0301,C0302,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,W0614,W0703,W0311

> > * Maximum line length: 80
> >
> > Please refer to the pylintrc file in the below link for all such rules.
> > Most of these rules are part of pylint standard.
> >
> > For now, I've not considered the indentation, be it 2 or 4 space. We
> > follow both these indentation (2 and 4) equally in our code, so far. If
> > we set this rule as say 4, the scoring for most of our code goes in
> > negative in the scale of 10! If anyone strongly believe that we MUST
> > follow one standard, say 4 space for indentation, even if it also mean,
> > modifying our existing code, please speak up!
> >
> > Based on the above rules I've run pylint report for few python scripts,
> > and they are accessible from here. The reports are not intuitive, but it
> > should give us an hint on current coding standard:
> > http://people.apache.org/~bhuvan/pylint/

I can't see all the results in there - e.g. the www/ directory just has
a summary page with no links to actual lists of results - but I can see
some results. If we are going to pay attention to the results, we will
need to see them in a more accessible form, such as a single plain text
list of all errors in all modules. Is that possible?

> > From here, I propose to fix all the error and fatal errors in our code.

Great. Thank you.

- Julian

> > The errors are the messages that begin with 'E' character. Ex: E0602,
> > undefined variable. The fatal ones are the messages that begin with 'F'
> > character. Ex: F0001, unable to import. For a complete list of such
> > pylint messages and corresponding code, please refer to this link:
> > http://people.apache.org/~bhuvan/pylint/list-msg-codes.txt
> >
> > We should set a minimum score for any python code that is checked-in our
> > repository. I suggest it to be 9.80/10.00. Comments are welcome. Any
> > questions, let me know. Thank you.
> >
> > [1] http://bit.ly/8ujHS8
>
Received on 2009-12-18 10:16:02 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.