Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python tool that builds a dependency diagram for methods of a class [closed]

I'm digging into a huge legacy Python class that has a lot of methods. I eventually break complex ones into smaller pieces so the amount of methods increases even more. I wonder if there is a tool that can scan the Python code and build some kind of dependency diagram for its methods.

I define method x() to be a dependency of method y() if x() is called at least once in y().

I could use such a tool to isolate (if possible) subsets of class methods that have no external dependencies (all their dependencies are methods from the same subset).

I'm planning to move some functionality into other classes and I think that such an approach would help me to decide which parts to extract from the initial huge class.

Edit: I would really like a command-line tool.

like image 263
Anonymous Avatar asked Apr 28 '09 14:04

Anonymous


People also ask

How do you add dependencies in Python?

To install Python dependencies for a private IP environment inside a perimeter, you can: Use a private PyPI repository hosted in your VPC network. Use a proxy server VM in your VPC network to connect to a PyPI repository on the public internet. Specify the proxy address in the /config/pip/pip.

What is module dependency graph?

1. Graph representing the system modules as nodes and the module-level relationships as edges between these nodes. Learn more in: Software Module Clustering Using Bio-Inspired Algorithms. Find more terms and definitions using our Dictionary Search.

How do I view the dependency tree in Visual Studio?

Dependency diagrams for . NET Core projects are supported starting Visual Studio 2019 version 16.2. On the Architecture menu, choose New Dependency Diagram. Under Templates, choose dependency diagram.


2 Answers

Have you looked at Snakefood yet? It looks like it's exactly what you're looking for.

like image 189
joce Avatar answered Oct 09 '22 00:10

joce


Have you tried pydev? It's a python extension for eclipse. I believe it allows you to use the "call hierarchy" feature of Eclipse to view a call graph for a given method. It's not quite what you want but maybe it's enough to get started.

like image 25
sk. Avatar answered Oct 08 '22 23:10

sk.