Re: static analysis and other tools for checking Python code

2016-03-04 Thread Paul Wise
On Fri, Mar 4, 2016 at 11:11 PM, Nicolas Chauvat wrote:

> It does recursively scan for Python files:

That doesn't pick up Python scripts that don't have .py in their name.

I couldn't get it to work with files in the current directory:

$ touch __init__.py
$ echo 'a = b+1' > bar.py
$ pylint -E .
No config file found, using default configuration

Should I file bugs about these two issues?

It does work with subdirectories as you pointed out though.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise



Re: static analysis and other tools for checking Python code

2016-03-04 Thread Paul Wise
On Fri, Mar 4, 2016 at 10:14 PM, Daniel Stender wrote:

> BTW there's also Prospector which provides a uniform interface to many 
> individual linters:
> https://packages.qa.debian.org/p/prospector.html

Already on the TODO list:

https://anonscm.debian.org/cgit/collab-maint/check-all-the-things.git/tree/data/python

If it is possible to disable the prospector checks for things that
prospector runs that c-a-t-t already runs, please feel free to add a
check that runs prospector. It seems that prospector is only a
wrapper, it doesn't do any checks only implemented in it though?

-- 
bye,
pabs

https://wiki.debian.org/PaulWise



Re: static analysis and other tools for checking Python code

2016-03-04 Thread Nicolas Chauvat
On Fri, Mar 04, 2016 at 09:33:17PM +0800, Paul Wise wrote:
> Do you know if pylint can recursively scan for Python files rather
> than being passed the names of Python files?

It does recursively scan for Python files:

$ tree bar/
bar/
├── baz
│   ├── gloo.py
│   └── __init__.py
├── foo.py
└── __init__.py
$ cat bar/**/*py
b = a-1
a = b+1
$ pylint -E bar/
No config file found, using default configuration
* Module bar.foo
E:  1, 4: Undefined variable 'b' (undefined-variable)
* Module bar.baz.gloo
E:  1, 4: Undefined variable 'a' (undefined-variable)

> Incidentally, I got a patch for c-a-t-t to support pylint from the
> author of yamllint:
> 
> https://anonscm.debian.org/cgit/collab-maint/check-all-the-things.git/patch/?id=4dc0a9ca929fa3488ab93cb4e997101d52bbe8a8

Nice!

-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  



Re: static analysis and other tools for checking Python code

2016-03-04 Thread Daniel Stender
On 03.03.2016 01:38, Paul Wise wrote:
> On Thu, Mar 3, 2016 at 7:52 AM, Jeremy Stanley wrote:
>> ...
> 
> All of flake8, hacking, bandit, pep257, clonedigger and more are on
> the TODO list:
> 
> https://anonscm.debian.org/cgit/collab-maint/check-all-the-things.git/tree/data/python
> 
> FYI pep257 is definitely packaged:
> 
> https://packages.debian.org/search?keywords=pep257
> 
>> I can probably think up more that I've used, but the above rise to
>> the top of my list.
> 
> More suggestions would be useful but most useful would be actual
> tests. They are very simple to add if you know how to run the tools.

BTW there's also Prospector which provides a uniform interface to many 
individual linters:
https://packages.qa.debian.org/p/prospector.html

Cheers,
DS

-- 
4096R/DF5182C8
http://www.danielstender.com/blog/



Re: static analysis and other tools for checking Python code

2016-03-04 Thread Paul Wise
On Fri, Mar 4, 2016 at 5:24 PM, Nicolas Chauvat wrote:

> I hope this helps making clearer what pylint can be used for. I had a
> look at the README and I suppose the intro section at the top could
> state the above goal with more clarity.

It does, thanks.

Do you know if pylint can recursively scan for Python files rather
than being passed the names of Python files?

Incidentally, I got a patch for c-a-t-t to support pylint from the
author of yamllint:

https://anonscm.debian.org/cgit/collab-maint/check-all-the-things.git/patch/?id=4dc0a9ca929fa3488ab93cb4e997101d52bbe8a8

-- 
bye,
pabs

https://wiki.debian.org/PaulWise



Re: static analysis and other tools for checking Python code

2016-03-04 Thread Nicolas Chauvat
Hi,

On Fri, Mar 04, 2016 at 01:03:17PM +0800, Paul Wise wrote:
> > That would be https://pypi.python.org/pypi/PyChecker
> > 
> > Pylint has never run code from the source tree.
> 
> I wonder where I got that impression from.
> 
> What about from the module it is checking?
> 
> > "pylint " should work fine.
> 
> Unfortunately that needs the module installed to work.
> 
> Is there any way to make it scan the source tree instead?

It *does* read the source and scan the tree.

It *does*not* import or execute the code.

That is the very first goal of pylint: "detect code smells in python
code by staticaly analyzing the syntax tree read from the source".

  $ cat foo.py
  a = b+1
  $ pylint -E foo.py
  No config file found, using default configuration
  * Module foo
  E:  1, 4: Undefined variable 'b' (undefined-variable)
  $ mkdir bar
  $ mv foo.py bar
  $ touch bar/__init__.py
  $ pylint -E bar/
  No config file found, using default configuration
  * Module bar.foo
  E:  1, 4: Undefined variable 'b' (undefined-variable)

There is even a library named https://pypi.python.org/pypi/astroid
that was extracted out of pylint to make it easier for other tools to
do type inference (and other things) on Python's Abstract Syntax
Trees.

I hope this helps making clearer what pylint can be used for. I had a
look at the README and I suppose the intro section at the top could
state the above goal with more clarity.

-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances