Skip to main content

Keep requirements.txt in sync with what your code actually imports.

Project description

importsync

Keep requirements.txt in sync with what your code actually imports.

reqsync 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

  1. Scan — walks all .py files and extracts every import and from ... import statement using ast.parse()
  2. Resolve — maps import names to pip package names
  3. Diff — compares the resolved set against your requirements.txt.
  4. 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

importsync-0.1.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

importsync-0.1.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file importsync-0.1.1.tar.gz.

File metadata

  • Download URL: importsync-0.1.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for importsync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 79f2da6722aed1268facbc82e92f063baf5d26b186c6d93d42dd86886b269b9c
MD5 e7c7d1732aca777422cd3f33ee25512a
BLAKE2b-256 14dd3601b3433c8550155b7949449041314f6501fcfc4a4d33e6ddfe22345ec4

See more details on using hashes here.

File details

Details for the file importsync-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: importsync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for importsync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6147ced088a047636457f1ec4e3c7136e64cc86c38f2a9dbf25c351d63988cc
MD5 7e443500748918c321663a1fbb012877
BLAKE2b-256 a9369079e05236878341f6c8b8b391e8923965ee9030e3295359beb84c647bac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page