PySmell is a python IDE completion helper.
It tries to statically analyze Python source code, without executing it, and generates information about a project's structure that IDE tools can use.
The first target is Vim, because that's what I'm using and because its completion mechanism is very straightforward.
Download and Installation
PySmell's code is available at GitHub. You can click 'Download' to get it as a zip/tar if you don't have git installed.
Extract and drop the pysmell package somewhere in your
PYTHONPATH. Distutils support coming soon - patches welcome!
To generate a PYSMELLTAGS file, use:
cd /root/of/project /dir/of/pysmell.py .
If you want to specifically include or exclude some files or directories (eg. tests), you can use:
/dir/of/pysmell.py [Package Package File File ...] [-x Excluded Excluded ...]
Check for more options by invoking
pysmell.py without any arguments
Using external libraries
PySmell can handle completions of external libraries, like the Standard Library and Django.
To use external libraries, you have to first analyze the libraries you want, eg. for stdlib:
pysmell.py . -x site-packages test -o ~/PYSMELLTAGS.stdlib
This will create PYSMELLTAGS.stdlib in your HOME. Copy that in the root of your project, and repeat for other libraries by changing the extension. Note that you still have to have a root PYSMELLTAGS file with no extension at the very root of your project.
Sometimes it's useful to not pollute global namespaces with tags of sub-projects. For example, assume that there is a Tests package, which has hundreds of tests, together with a few testing-related modules. You only want to see these completions when working on test file.
To accomplish that, you can put PYSMELLTAGS.* files inside subdirectories, and they will be used only when you're working on a file somewhere in that directory or its children.
/dir/of/pysmell.py Tests/FunctionalTest.py Tests/UndoTestCase.py -o Tests/PYSMELLTAGS.Tests
The information in FunctionalTest and UndoTestCase will only be accessible when editing a file inside the Tests package.
To use PySmell omnicompletion from inside Vim, you have to have:
- Python support
- The pysmell package in your PYTHONPATH (sometimes Vim is silly about this)
- Source pysmell/pysmell.vim
:set omnifunc=pysmell#CompleteNote: If you want to always use pysmell for python, do:
autocmd FileType python set omnifunc=pysmell#Complete
- [OPTIONAL] Select a matcher of your liking - look at pysmell.vim for options. Eg:
You can then use ^X^O to invoke Vim's omnicompletion.
You can generate debugging information by doing:
Debug information will be appended in that buffer, copy and paste it into an email.
Look in the TODO first. Vote up on issues that you feel strongly about!
Send me an email at firstname.lastname@example.org. If you can create a unit test that exposes that behaviour, it'd be great!October 13, 2008, 10:45 p.m.