Crates.io | marui |
lib.rs | marui |
version | 0.2.0 |
source | src |
created_at | 2023-02-24 13:42:40.676842 |
updated_at | 2023-03-22 12:23:11.068565 |
description | Find circular imports in a Python project. |
homepage | |
repository | https://github.com/jan-krecke/marui |
max_upload_size | |
id | 793584 |
size | 25,112 |
At work I work with a relatively large Python code base. Sometimes I find myself accidentally adding circular dependencies between modules. This leads to the classical
ImportError: cannot import name 'A' from partially initialized module 'B'
marui mitigates this problem by finding circular imports before you run your CI suite.
In a Python project (characterized by a pyproject.toml
being present), simply run
$ marui .
In its current version (0.2.0
), marui
can only find imports from within project that are imported with their fully qualified path. For example, if you have a project structure like this:
.
├── pyproject.toml
├── my_package
│ ├── a
│ │ ├── __init__.py
│ │ └── b.py
│ └── c
│ ├── __init__.py
│ └── d.py
└── ...
b.py
can import d.py
as
import my_package.c.d
but as not as
import c.d
This will be addressed in the next version.
If you have cloned this repository, build and install marui with cargo
:
$ gh repo clone jan-krecke/marui
$ cd marui
$ cargo install --path .
Alternatively, just get marui
directly from crates.io
:
$ cargo install marui
If you want to use this tool and find any problems, feel free to open a PR or an issue :-).