PyLint plugin: are you interested?

32 views
Skip to first unread message

casbon

unread,
Jun 5, 2008, 7:33:42 AM6/5/08
to nose-users, pf...@pobox.com, j...@pobox.com
Hi,

I have a initial cut at a PyLint plugin, and I wondered if anyone
wants to take a quick look?

No public repo, doesn't seem worth it at the moment. I can mail you
the code if you want.

thanks,
James

Pete

unread,
Jun 5, 2008, 9:39:36 AM6/5/08
to nose-...@googlegroups.com

Yes please. Want to just attach it to a email to the list if it's not
too big?

Kumar McMillan

unread,
Jun 5, 2008, 10:59:51 AM6/5/08
to nose-...@googlegroups.com, pf...@pobox.com, j...@pobox.com

you could run python setup.py register upload -s to place it on pypi.
That wouldn't require a repo and would make it easy_install'able

casbon

unread,
Jun 6, 2008, 5:31:29 AM6/6/08
to nose-users
Good idea. I uploaded it as NoseLint. At the moment it works OK, but
there are a few things worth saying.

The plugin hooks into loadTestFromModule to harvest lint messages
about a module. It returns the messages as one test case, which fails
if there are any messages. So you get one failure per file (or though
one failure per message would be easy to configure as well). At the
end of the run, it reruns lint against all files collected to create
the global report. The plugin will load your pylintrc files, but it
is low on configuration options until I figure out how it would be
used.

The horrible part of the plugin is that it monkeypatches
unittest._TextTestResult._exc_info_to_string

This is necessary to create a reasonable 'traceback' that corresponds
to the file being tested. Otherwise all the tracebacks point to the
same wrong place. Since you cannot fake traceback objects AFAIK, the
only way around this would be for the plugin API to offer a
formatTraceback hook (non chainable) that would prevent unittest
trying to format the traceback and let the plugin handle it.

Anyway, let me know what you think,

thanks,
James

John J Lee

unread,
Jun 6, 2008, 2:37:47 PM6/6/08
to nose-users
On Fri, 6 Jun 2008, casbon wrote:
[...]

> This is necessary to create a reasonable 'traceback' that corresponds
> to the file being tested. Otherwise all the tracebacks point to the
> same wrong place. Since you cannot fake traceback objects AFAIK, the
> only way around this would be for the plugin API to offer a
> formatTraceback hook (non chainable) that would prevent unittest
> trying to format the traceback and let the plugin handle it.
[...]

http://groups.google.co.uk/group/nose-users/browse_frm/thread/54a1b4d48db64706/

class Code(object):
def __init__(self, code):
self.co_filename = code.co_filename
self.co_name = code.co_name

class Frame(object):
def __init__(self, frame):
self.f_globals = {"__file__": frame.f_globals["__file__"]}
self.f_code = Code(frame.f_code)

class Traceback(object):
def __init__(self, tb):
self.tb_frame = Frame(tb.tb_frame)
self.tb_lineno = tb.tb_lineno
if tb.tb_next is None:
self.tb_next = None
else:
self.tb_next = Traceback(tb.tb_next)


John

Reply all
Reply to author
Forward
0 new messages