Sage and pylint

149 views
Skip to first unread message

VulK

unread,
Sep 16, 2016, 6:55:33 AM9/16/16
to sage-...@googlegroups.com
Dear all,
I am trying to use pylint to validate some of the code in a patch I wrote for
sage and, unsurprisingly, I am getting several complaints because my
system-wide pylint can't resolve modules like sage.something.

What is the correct way of doing this? Is there any other alternative to
pylint that I should use instead?
Thanks
S.


Thierry

unread,
Sep 16, 2016, 7:08:13 AM9/16/16
to sage-...@googlegroups.com
Hi,

note that https://ask.sagemath.org is a nice place to ask such questions
that are not related to sage development but still interesting.

Anyway, Sage uses its own Python install, so you should install pylint
within Sage and import it from there.

A priori, the following should work:

sage -pip install pylint

If you really want to use the pylint from your distro, you should add the
path to your distro's '/${WHATEVER}/python2.7/dist-packages' directory to
Sage's PYTHONPATH, at your own risks.

Ciao,
Thierry
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

VulK

unread,
Sep 16, 2016, 7:12:21 AM9/16/16
to sage-...@googlegroups.com
Hi,
I thought this was a question for sage-devel because it is about tickets I am
currently working on (#21254 specifically). Sorry for the wrong assumption.

I did try sage -pip install pylint before posting but the results were
identical (even launching it from within sage -sh)

Thanks
S.


* Thierry <sage-goo...@lma.metelu.net> [2016-09-16 13:08:10]:

Erik Bray

unread,
Sep 22, 2016, 11:24:09 AM9/22/16
to sage-devel
On Fri, Sep 16, 2016 at 1:12 PM, VulK <etn4...@gmail.com> wrote:
> Hi,
> I thought this was a question for sage-devel because it is about tickets I
> am currently working on (#21254 specifically). Sorry for the wrong
> assumption.
>
> I did try sage -pip install pylint before posting but the results were
> identical (even launching it from within sage -sh)

That sounds suspicious, though I admit I haven't tried it myself yet.
With what options did you run pylint? If it installed correctly into
Sage's Python it should work.

I wouldn't mind getting that working myself. It would be very nice to
see what cleanup pylint can suggest (though a foolish consistency is
the hobgoblin of little minds--I suspect pylint will require a lot of
exceptions for sage :)

VulK

unread,
Sep 22, 2016, 11:38:10 AM9/22/16
to sage-...@googlegroups.com
Hi Erik,
no options. As an example of the errors I get let's consider the ticket I am
working on (#21254).

I installed pylint via

$ sage -pip install pylint

my sage install is in /opt/sage so

$ /opt/sage/local/bin/pylint /opt/sage/src/sage/algebras/cluster_algebra.py | grep E: | head
No config file found, using default configuration
E:327, 0: No name 'morphism' in module 'sage.categories' (no-name-in-module)
E:335, 0: No name 'constructor' in module 'sage.matrix' (no-name-in-module)
E:337, 0: No name 'cachefunc' in module 'sage.misc' (no-name-in-module)
E:338, 0: No name 'misc_c' in module 'sage.misc' (no-name-in-module)
E:339, 0: No name 'free_module_element' in module 'sage.modules' (no-name-in-module)
E:341, 0: No name 'integer' in module 'sage.rings' (no-name-in-module)
E:342, 0: No name 'integer_ring' in module 'sage.rings' (no-name-in-module)
E:347, 0: No name 'element_wrapper' in module 'sage.structure' (no-name-in-module)
E:348, 0: No name 'parent' in module 'sage.structure' (no-name-in-module)
E:349, 0: No name 'sage_object' in module 'sage.structure' (no-name-in-module)

I get many more warnings about lines being too long, having too many/too few
methods etc but I do not care about those.

Something weird: line 326 and 327 are
from sage.categories.homset import Hom
from sage.categories.morphism import SetMorphism
pylint complains only about the second.

Best
S.




* Erik Bray <erik....@gmail.com> [2016-09-22 17:24:05]:

Dima Pasechnik

unread,
Sep 23, 2016, 5:11:42 AM9/23/16
to sage-devel, etn4...@gmail.com


On Thursday, September 22, 2016 at 3:38:10 PM UTC, Salvatore Stella wrote:
Hi Erik,
no options. As an example of the errors I get let's consider the ticket I am
working on (#21254).

I installed pylint via

        $ sage -pip install pylint

my sage install is in /opt/sage so

        $ /opt/sage/local/bin/pylint /opt/sage/src/sage/algebras/cluster_algebra.py | grep E: | head

IMHO you should run pylint in sage shell, i.e. first do "sage -sh" and only at its prompt start pylint.
The way you try doesn't set the environment right.

HTH,
Dima

Erik Bray

unread,
Sep 23, 2016, 7:18:24 AM9/23/16
to sage-devel
I don't think pylint supports Cython modules, so that would probably do it.
Reply all
Reply to author
Forward
0 new messages