Keep requirements.txt in sync with what your code actually imports.
Project description
importsync
Keep
requirements.txtin sync with what your code actually imports.
importsync scans every .py file in your project using Python's AST parser, figures out which third-party packages you import, and cross-references that against your requirements.txt — showing you what's missing, unused, or unpinned.
Zero runtime dependencies. Works on any Python 3.8+ project.
Install
pip install importsync
Usage
Check for drift
importsync check
Show file locations of missing imports
importsync check --locations
Fix — add missing packages automatically
importsync fix
Preview what fix would do (no writes)
importsync fix --dry-run
Fix and pin to installed versions
importsync fix --pin
Also remove unused packages (careful — may include transitive deps)
importsync fix --remove-unused
See all third-party imports found in the project
importsync scan
How it works
- Scan — walks all
.pyfiles and extracts everyimportandfrom ... importstatement usingast.parse() - Resolve — maps import names to pip package names
- Diff — compares the resolved set against your
requirements.txt. - Fix — rewrites
requirements.txt, preserving comments and existing pins.
Options reference
| Flag | Command | Description |
|---|---|---|
--root DIR |
all | Project root to scan (default: .) |
--req FILE |
all | Requirements file (default: requirements.txt) |
--no-tests |
all | Exclude tests/ directories |
--locations |
check | Show file:line for each missing import |
--no-unpinned |
check | Hide unpinned warnings |
--dry-run |
fix | Preview without writing |
--pin |
fix | Pin to installed version when adding |
--remove-unused |
fix | Remove unused entries (use with care) |
License
MIT
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file importsync-0.1.5.tar.gz.
File metadata
- Download URL: importsync-0.1.5.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
903af594deb3dc9b930ee1f327cc0a88547c3ee19c6d8c9a827ce0b97f96e442
|
|
| MD5 |
f6f9727ac1d53d9a8fe6970dc0f252a7
|
|
| BLAKE2b-256 |
a94ada96c2a0aa8dbce3c64a7bb78cd1788b499ef985150a7350f454f49eb69c
|
File details
Details for the file importsync-0.1.5-py3-none-any.whl.
File metadata
- Download URL: importsync-0.1.5-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0436c9c1a322912f1567321d9a40898bacce927210c3503c7aaebf5454dc106a
|
|
| MD5 |
b1f1fa26dd37a19d2e855dc8ee3aab53
|
|
| BLAKE2b-256 |
c7a06217fff64aede541b66dd6bbe8923625a2fd5efb77761947982cab254f91
|