Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static code analysis in Python?

Which helpful static code analysis can you recommend for Python. I believe they are useful for refactoring code. I know

  • snakefood for module dependencies
  • pycallgraph for dynamic call graphs
  • pylint for bugs

Are there static call analyzers? If I wanted to program a custom one, which would be the easiest way?

What other type of static code checks can you think of? Or maybe even some Python magic like ABCs?

EDIT: I've found that either using http://docs.python.org/3.3/library/ast.html or maybe even http://www.astroid.org/ can be used to program some custom parser. Then one can use graphviz to visualize or even PlantUML for UML graphs.

like image 342
Gerenuk Avatar asked Oct 08 '22 00:10

Gerenuk


2 Answers

check out pychecker and pyflakes. There was a famous question to discuss the pylint-pychecker-or-pyflakes

like image 178
zhutoulala Avatar answered Oct 13 '22 11:10

zhutoulala


this is a very powerful python type inferencer https://github.com/yinwang0/pysonar2

it has strong bug check ability but it's not exposed through its interface, but I assume you could do many awesome checks based on it.

like image 20
tazdingo Avatar answered Oct 13 '22 09:10

tazdingo