Leo's new pylint command

44 views
Skip to first unread message

Edward K. Ream

unread,
Jul 18, 2014, 1:29:30 PM7/18/14
to leo-e...@googlegroups.com
As of a recent rev, Leo now has a new pylint command.  If pylint is installed, it will run pylint on all Python @<file> nodes of a tree.

The command first looks down the tree, and runs each file found.  If none are found, it runs pylint on the nearest parent Python @<file> tree.

Using this command is *much* easier and more flexible than the previous way of laboriously specifying lists of files to check.  As a result, I have easily checked sets of files never previously checked.

Edward

P.S. Leo waits for pylint while executing the command.  Code is in place to spawn processes without waiting using g.execute_shell_commands, but it doesn't seem to work: eventually all console output disappears.

EKR

Terry Brown

unread,
Jul 18, 2014, 6:37:03 PM7/18/14
to leo-e...@googlegroups.com
On Fri, 18 Jul 2014 10:29:30 -0700 (PDT)
"Edward K. Ream" <edre...@gmail.com> wrote:

> As of a recent rev, Leo now has a new pylint command. If pylint is
> installed, it will run pylint on all Python @<file> nodes of a tree.
>
> The command first looks down the tree, and runs each file found. If
> none are found, it runs pylint on the nearest parent Python @<file>
> tree.
>
> Using this command is *much* easier and more flexible than the
> previous way of laboriously specifying lists of files to check. As a
> result, I have easily checked sets of files never previously checked.

For me it just says:

('pylint rc file not found:', u'/mnt/usr1/usr1/home/tbrown/.leo/leo/test/pylint-leo-rc.txt')
pylint: done

When that's resolved, are there commands for jumping to the next /
previous issue? I had that set up as a script once, I can dig that up
if it's useful.

> P.S. Leo waits for pylint while executing the command. Code is in
> place to spawn processes without waiting using
> g.execute_shell_commands, but it doesn't seem to work: eventually all
> console output disappears.

Completely off topic, but thanks for the opportunity to share ;-)

I recently wanted a Python 3.4 app. to call a Python 2.7 app, and
wanted the long running (4 hours sometimes) 2.7 app to talk back to the
3.4 app so the latter could display progress info.

I gave up trying to find a clean way to do it using stdin/out
conversation. Sarge has an expect() method, but I didn't want to use
that. subprocess module is just full of warnings about deadlocks.

Sooo... and this made my day, I had the 3.4 app pass the 2.7 app the
address of an XMPRPC server the 2.7 app could use to send progress
messages back to the 3.4 app. +10 for Python making this kind of thing
so easy.

But... it gets better... I was thinking I needed to add a bunch of
calls to the RPC proxy in the 2.7 code, but it was already using
logging, so a simple subclass of HTTPHandler and I was done, all the
chatter from the 2.7 app via logging.SOMETHING() was available in the
3.4 app to keep the user updated on progress.

http:/xkcd.com/353/

Cheers -Terry

> EKR
>

Edward K. Ream

unread,
Jul 18, 2014, 7:28:47 PM7/18/14
to leo-editor
On Fri, Jul 18, 2014 at 5:36 PM, 'Terry Brown' via leo-editor
<leo-e...@googlegroups.com> wrote:

> For me it just says:
>
> ('pylint rc file not found:', u'/mnt/usr1/usr1/home/tbrown/.leo/leo/test/pylint-leo-rc.txt')
> pylint: done

Pylint will print a lot of errors if the rc file doesn't exist.

Just copy the the file from the leo/test directory to ~/.leo/test

> When that's resolved, are there commands for jumping to the next /
> previous issue? I had that set up as a script once, I can dig that up
> if it's useful.

No. That would be useful.

> Completely off topic, but thanks for the opportunity to share ;-)
[big snip]

> so a simple subclass of HTTPHandler and I was done, all the
> chatter from the 2.7 app via logging.SOMETHING() was available in the
> 3.4 app to keep the user updated on progress.

I'm not following you closely, but I'm glad you're happy :-)

> http:/xkcd.com/353/

Hehe.

Edward

Kent Tenney

unread,
Jul 18, 2014, 8:58:12 PM7/18/14
to leo-editor
for me it says
('pylint rc file not found:',
u'/home/ktenney/develop/leo/test/pylint-leo-rc.txt')

I started Leo from /home/ktenney/develop

Maybe if a user copy isn't found Leo could fall back on the one in the
Leo repository, I'm sure it's a good one.
> --
> You received this message because you are subscribed to the Google Groups "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
> To post to this group, send email to leo-e...@googlegroups.com.
> Visit this group at http://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.

Terry Brown

unread,
Jul 18, 2014, 11:52:31 PM7/18/14
to leo-e...@googlegroups.com
On Fri, 18 Jul 2014 18:28:46 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

> On Fri, Jul 18, 2014 at 5:36 PM, 'Terry Brown' via leo-editor
> <leo-e...@googlegroups.com> wrote:
>
> > For me it just says:
> >
> > ('pylint rc file not found:',
> > u'/mnt/usr1/usr1/home/tbrown/.leo/leo/test/pylint-leo-rc.txt')
> > pylint: done
>
> Pylint will print a lot of errors if the rc file doesn't exist.
>
> Just copy the the file from the leo/test directory to ~/.leo/test

After that I get

Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named core.leoGlobals
pylint: done

So if I run Leo with leo on the PYTHONPATH...

(thanks for fixing --minimize, btw)

then I get

pylint: eet2.py
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named core.leoGlobals
pylint: done

eet2.py being the name of the @auto file I was on.

so Ctrl-b on `import core.leoGlobals as g` works, but not Alt-X pylint.

Cheers -Terry



Edward K. Ream

unread,
Jul 19, 2014, 6:51:38 AM7/19/14
to leo-editor
On Fri, Jul 18, 2014 at 7:57 PM, Kent Tenney <kte...@gmail.com> wrote:

> Maybe if a user copy isn't found Leo could fall back on the one in the
> Leo repository, I'm sure it's a good one.

Sorry for the bad documentation. Here is the latest checkin log:

QQQ
The pylint now searches for pylint-leo-rc.txt in ~/.leo, then leo/test.

If no rc file is found, the pylint command reports the locations searched.
QQQ

Edward

Edward K. Ream

unread,
Jul 19, 2014, 7:03:45 AM7/19/14
to leo-editor
On Fri, Jul 18, 2014 at 10:52 PM, 'Terry Brown' via leo-editor
> So if I run Leo with leo on the PYTHONPATH then I get
>
> pylint: eet2.py
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> ImportError: No module named core.leoGlobals
> pylint: done

Leo runs this in a separate process::

command = '%s -c "import leo.core.leoGlobals as g; g.run_pylint(%s)"' % (
sys.executable,args)

which should be about the same as running this from the console::

python -c "import leo.core.leoGlobals as g; g.run_pylint(
fn=<path to your file>,rc=<path to rc file>"

To make this work, I have the following in sitecustomize.py:

table = (
r'C:\leo.repo\leo-editor',
etc...
)
for path in table:
sys.path.append(path)

Does that work for you?

Edward
Reply all
Reply to author
Forward
0 new messages