[IPython-dev] Static code analysis of IPython Notebook cell
takowl at gmail.com
Mon Jul 7 09:47:13 EDT 2014
On 7 July 2014 00:20, Thomas Wiecki <thomas.wiecki at gmail.com> wrote:
> With my limited understanding of the IPyNB internals I would see three
> ways this could be achieved:
> * There is a hook in the IPyNB I can use like the magic
> * I have to change the IPyNB client code to do the analysis before it's
> sent to the kernel.
> * I change the kernel to do the analysis.
> Which of these is the best? Can someone point me to the relevant code
> section I would need to make changes to?
I think you can make use of the hooks already in the kernel. If you're just
checking the AST, it's fairly straightforward: just register an AST
transformer as described here:
. It doesn't need to do any transformations: you can simply inspect the
code and return it unchanged. Or you can replace it all with Pass() to
prevent the cell from executing. It would still look as if it had executed
from the frontend, though.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev