PyChecker messages
Eric Brunel
eric_brunel at despammed.com
Tue Jan 11 04:00:51 EST 2005
Frans Englich wrote:
> Hello,
>
> I take PyChecker partly as an recommender of good coding practice, but I
> cannot make sense of some of the messages. For example:
>
> runner.py:878: Function (main) has too many lines (201)
>
> What does this mean? Cannot functions be large? Or is it simply an advice that
> functions should be small and simple?
This is an advice. You can set the number after which the warning is triggered
via the maxLines option in your .pycheckrc file.
> runner.py:200: Function (detectMimeType) has too many returns (11)
>
> The function is simply a long "else-if" clause, branching out to different
> return statements. What's wrong? It's simply a "probably ugly code" advice?
Same thing; the corresponding option in .pycheckrc is maxReturns. Other options
that may interest you are maxBranches, maxArgs, maxLocals and maxReferences.
Please see PyChecker's documentation for more details.
> A common message is these:
>
> runner.py:41: Parameter (frame) not used
>
> But I'm wondering if there's cases where this cannot be avoided. For example,
> this signal handler:
>
> #-------------------------------------------
> def signalSilencer( signal, frame ):
> """
> Dummy signal handler for avoiding ugly
> tracebacks when the user presses CTRL+C.
> """
> print "Received signal", str(signal) + ", exiting."
> sys.exit(1)
> #-------------------------------------------
>
> _must_ take two arguments; is there any way that I can make 'frame' go away?
See/set the unusedNames option in .pycheckrc; this is a list of names for which
this kind of warnings are not triggered. If you set for example:
unusedNames = [ 'dummy' ]
in .pycheckrc and if you define your function with:
def signalSilencer(signal, dummy):
...
the warning will not be triggered.
BTW, if your signal handler is just here to catch Ctrl-C, you'd better do a
try/except on KeyboardInterrupt...
HTH
--
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list