pymport
About
A lightweight Python linter for checking unused imports in your Python files.
Features
- 🧹 Detects unused or shadowed
importsthat linters like ruff may miss - 🚫 Use
noqacomments to ignore imports you want to keep - ⚙️ Minimalist CLI interface for easy integration in CI/CD pipelines
- 🐍 No external dependencies beyond the Python standard library
- ✅ 100% test coverage with automated tests
- 🔌 Provides pre‑commit hook integration for automated checks
A minimal typical example could be:
import os.path
print(os.curdir)
📦 Installation
To install pymport using pip, run the following command:
pip install pymport --upgrade
⚡ Quick Start
To run the linter on the current directory, use the following command:
pymport .
- This will check all Python files in the current directory and its subdirectories.
Command-Line Interface
Usage: pymport [FILE] [--help] [--quiet] [--ignore=DIR]
| Argument / Option | Description |
|---|---|
[FILE] |
Files or directories to lint. (Need at least one file or dir to check.) |
[--help] |
Show help message and exit. |
[--quiet] |
Decrease verbosity. |
[--ignore] |
Directory basename to ignore. Can be used multiple times. |
Output
When unused imports are detected, they will be reported in the following format:
path/to/file.py:LINE-NUMBER: UNUSED-IMPORT-NAME
Pre‑commit Integration
The linter can be easily integrated into your pre‑commit workflow.
Update your .pre-commit-config.yaml to include the pymport hook:
repos:
- repo: https://github.com/rmoralespp/pymport
rev: 0.0.6 # Use the latest commit hash or tag
hooks:
- id: pymport
args: ["."] # customize as needed
pass_filenames: false # needed if excluding files with --ignore
🛠️ Development
To contribute to the project, you can run the following commands for testing and documentation:
First, ensure you have the latest version of pip:
python -m pip install --upgrade pip
Running Tests
pip install --group=test --upgrade # Install test dependencies, skip if already installed
python -m pytest tests/ # Run all tests
python -m pytest tests/ --cov # Run tests with coverage
Running Linter
pip install --group=lint --upgrade # Install lint dependencies, skip if already installed
ruff check . # Run linter
🗒️ License
This project is licensed under the MIT license.
Metadata
Release files for pymport 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymport-0.0.7.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymport-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / pymport-0.0.7.tar.gz
| Download URL | pymport-0.0.7.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f53f74f6aa9e2f1567daacf4836dc1b869376249f04d2f80849a1a75cab8d92f
|
|
BLAKE2b-256 checksum How to use checksums |
45792c60d9ab46d0d39ab38846dea27fba95b232fcdaa2d8c29a3764f54d9dcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / pymport-0.0.7-py3-none-any.whl
| Download URL | pymport-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9908c5bd4321f7d9b86b057334668df7f4ec5f0559dd9a0b97b34f42fc283e80
|
|
BLAKE2b-256 checksum How to use checksums |
d23fc1fdf702ac431a52a0ca8895242bf9772ebbfaae11bba1b75bf77bda8006
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|