Python import checker
Project description
PyImportCheck
Pyimportcheck is a static code analyser for Python 3.
This project aims to provide quick detection of:
- circular imports flow
- missing exported symbols (special
__all__symbol) - bad package declaration (missing of
__init__.pyfiles)
Pyimportcheck analyses your code without actually running it. It checks for errors, enforces a coding standard, and can make suggestions about how the code could be refactored (see the screenshot above).
[!WARNING] This project was originaly designed for my personal use to quickly detect arbitrary "errors" (e.g exported symbols) in some "big" projects since the report from the python interpreter is not easy to interpret for some edge cases (like circular import)
Note that you probably want to use CodeQL with default python query that can perform the same job as my tool.
If you want to know what I plan to do with this project, you can check the Roadmap issue that evolves with time
Install
Install and update using pip or poetry:
pip install pyimportcheck
poetry add pyimportcheck
[!NOTE] Stable branches are named as
<version>(e.g0.1) (themasterhas been reserved for the next release), so, if you plan to build manually the project, do not forget to switch to the appropriate branch before !
How to use
You can use the --help flag to display information about what you can do with this tool.
Most of the time, you simply need to indicate the path name to the package or file you
want to check.
pyimportcheck /path/to/local/package
You can export any detected notification into a (rudumentary) JSON format with --json
followed by the output path. You can also use --json-only to only perform the export
without displaying anything:
pyimportcheck /path/to/local/file.py --json-only /path/to/json_output_file.json
Notes
[!TIP] I recommend you resolve each circular dependency in the order that they are displayed. This is because I do not detect if a circular import has already been detected (It will be the case in the future).
So, resolving one circular import can clear, at least, two errors (or more if you have a long loop)
[!CAUTION] This project only supports "absolute" imports
from <package> ... import ...andimport <package> .... Canonical imports (likefrom .<module> ... import ...) and special workarounds, like withtyping.TYPE_CHEKING, are not supported (ignored for now).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyimportcheck-0.1.6-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 5b69024cd209363e0224ddc3145e8323b73c6480414753b8594f41431f161a1d |
|
| MD5 | 09cf540e0dd3b4243b612cc0a079672b |
|
| BLAKE2b-256 | deb8d35db14acecf29a1604f6d7d590ea8400b42a26e856af03e7962c12c1a0a |