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.4.tar.gz (5.5 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.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sweepy_cli-0.1.4.tar.gz
  • Upload date:
  • Size: 5.5 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.4.tar.gz
Algorithm Hash digest
SHA256 1f3ddafdd3bca1ac9c27e597f83630aa7013f240d2849192bbc07d848d7dbd01
MD5 96553ecdb7aea28bbfb95217bcc48e89
BLAKE2b-256 8075e8d7d2c74cffb2c4cb082f3f6a67af71c96967d76163c94301d5daef65ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sweepy_cli-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 628ec4980be611dfe7698eded36608fc0db993dd98360cadf9614471a03431ac
MD5 2bd48d1a81bc0ba68ccedb6c30ceb9bc
BLAKE2b-256 c1c4354f2455ba8746c29e4f8246a875eb4408a541fdc62cc149083fc718ddd3

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