ronaldoussoren / modulegraph2

Modulegraph2 is a library for creating and introspecting the dependency graph between Python modules.
MIT License
11 stars 8 forks source link

Add single option to exclude standard library completely #26

Closed eric-nieuwland closed 1 year ago

eric-nieuwland commented 1 year ago

In the current version one needs to exclude each package in the standard library separately. Would be very welcome to be able to exclude the standard library more simply.

ronaldoussoren commented 1 year ago

What's your use case for excluding the entire standard library? I'm trying to keep the API of modulegraph2 fairly minimal.

Note that the following should work for excluding the standard library in Python 3.10 or later:

graph = modulegraph2.ModuleGraph(...)
graph.add_excludes(sys.stdlib_module_names)

In older versions you have to add the list of standard library names to you script because the sys attribute is not available.

eric-nieuwland commented 1 year ago

As a developer I want to see the import graph of my own software, without standard library and possibly without installed packages so I can analyse the import structure of my code as a support for refactoring.

And as I'm using this package through its command line interface I'd like the code snippet above available through the CLI.

ronaldoussoren commented 1 year ago

Closing this as my recent changeset adds an implementation for this.

eric-nieuwland commented 1 year ago

Yes, your version is so much cooler than my 10 minutes clutch!