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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sweepy_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 5.4 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.3.tar.gz
Algorithm Hash digest
SHA256 5a47080bda14cbfb8de7997ce1d4ca603c6964d7a7751f99a5b96863554ff555
MD5 19d131d5b020ce9ca1f4c083837ddc46
BLAKE2b-256 e4e75ce02b6ab8ef3c0e9f516f4d908be949cefcc8e2007ffe80f3f93dcf3fac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sweepy_cli-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d2aa68adbd5c3d48d3856aa9c560bcff5ab166e4db693f0cc3c1c285c138f959
MD5 24f7d9073fbad867a7eabca3532647a0
BLAKE2b-256 9afba9b7b27c7930d6669e940e7eb3ab7741445e19f1a167149da4312528601c

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