zyskarch / pytestarch

Test framework for software architecture based on imports between modules.
https://zyskarch.github.io/pytestarch/latest
Apache License 2.0
72 stars 7 forks source link

Feature: Add filter for external modules. #115

Closed zyskarch closed 1 month ago

zyskarch commented 1 month ago

If a parent external module is excluded by this, so will its child modules.

Closes #114.

Lenormju commented 1 month ago

I've run it on my codebase, and here a screenshot of the results (graphically) :

before_left_then_after_right

On the left is what was generated before. On the right is what is generated now (using external_exclusions=("itertools", "dataclasses", "...").

It helps greatly to reduce the noise, and thus understand the relationships between my modules and some others of the codebase, some third-parties, some stdlib). Next step for me would be to produce a better visualization, but that's on the networkx side (and that I'm not good at). I don't know if it is something you would be interested to add to pytestarch. I tried to put imports and __all__ in my packages' __init__.pys and only import from them from all the other modules, but it did not fool your library. Did you thought of that ?

But I think it works great as it is. I'll take a look at reviewing the code now.

zyskarch commented 1 month ago

Thank you for your review, I truly appreciate it! I'm glad it works and helps to simplify your visualisation.

If you manage to come up with an improved visualisation, I'd definitely be interested! In my experience, it can be a pretty tedious task, so I have not yet spend too much time on it...

I've incorporated your typing suggestion, and will release a new version in a couple of minutes.