Skip to main content

Sweep away unused imports from your codebase

Project description

sweepy

Sweep away unused imports from your codebase.

A minimal, zero-dependency Python tool that detects unused imports. Just point it at any local directory or GitHub URL.

Installation

pip install sweepy-cli

Usage

# Local directory
sweepy .
sweepy /path/to/repo

# GitHub URL (no clone needed)
sweepy https://github.com/user/repo

# Specific branch
sweepy https://github.com/user/repo/tree/develop
sweepy https://github.com/user/repo/tree/feature/new-api

Options

# Exclude directories
sweepy . --exclude-dir migrations --exclude-dir tests

# Exclude files
sweepy . --exclude-file conftest.py

Python API

from sweepy import analyze

result = analyze("https://github.com/user/repo")

print(result.summary())

for item in result.unused_imports:
    print(f"{item.file}:{item.line} - {item.module}")

Example Output

============================================================
SWEEPY ANALYSIS REPORT
============================================================
Repository: https://github.com/user/repo
Files analyzed: 42
Files skipped: 3
Unused imports: 5

------------------------------------------------------------

src/utils.py
   Line   3: json
   Line   7: typing

src/main.py
   Line   1: os
   Line   4: sys
   Line   5: re

Why sweepy?

sweepy ruff autoflake
Zero dependencies O O X
GitHub URL support O X X
Single purpose O X X
Setup required None Config Config

sweepy does one thing: find unused imports. No config files, no complex rules, no setup.

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

sweepy_cli-0.1.7.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

sweepy_cli-0.1.7-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file sweepy_cli-0.1.7.tar.gz.

File metadata

  • Download URL: sweepy_cli-0.1.7.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sweepy_cli-0.1.7.tar.gz
Algorithm Hash digest
SHA256 d70f3fe8c38c9c5bae44bfa8ed3b971edd09e96d626e8d0f0a98979a7e4247f6
MD5 38839b08d8a3d32a92172243d4e2b773
BLAKE2b-256 7186509b9775196600d916e2faa219660c617c209d647f957b315073afad3c7b

See more details on using hashes here.

File details

Details for the file sweepy_cli-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: sweepy_cli-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sweepy_cli-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 25d9b71314d094378c045a466fe876d076a5037470dc92d6d8100c7bbabd1883
MD5 4d755862a8cc8fe4867c9ec61753af63
BLAKE2b-256 d3ee73c9574f2fb454a17f3e11bc3f992880b10e5ed566ab0de812d53ee22435

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