Check out this post: PySonar: a Static Analyzer for Python. PySonar is a tool that infers types using abstract interpretation (partially executing) of code. It finds all possible execution paths of your program and finds all possible types of all variables.
There are basically three versions of PySonar:
- Open-sourced Java (Jython indexer)
- Closed-sourced Java (Hidden in Google)
- Open-sourced Python (mini-pysonar)
None of them (except of closed source one) is fully implemented. But the basic idea is that you can use it as a basis for your work.