Skip to main content

Clean-Py 🧹

License: MIT

CLI tool for automated Python code cleanup and standardization. Formats both .py and .ipynb files using industry-standard tools.

Features

  • 🔄 Import optimization (autoflake)
  • 📝 Import sorting (isort)
  • ✨ Code formatting (black)
  • 📓 Notebook cleanup
    • Clear cell outputs
    • Reset execution counts
    • Format code cells

Installation

# Via pip
pip install clean-py

# Or from source
git clone https://github.com/samhardyhey/clean_py
cd clean_py
pip install .

Usage

# Clean single file
clean_py notebook.ipynb
clean_py script.py

# Clean directory
clean_py path/to/dir

# Selective cleaning
clean_py path/to/dir -py True -isort True -black False -autoflake False

Development

Development Workflow

  1. Create a new branch from dev for your feature/fix
  2. Make your changes and ensure tests pass
  3. Submit a pull request to dev
  4. After review and approval, merge to dev
  5. When ready for release, create a pull request from dev to main

Project Structure

  • src/clean_py/ - Main package code
  • tests/ - Test files

Common Development Commands

See the Makefile for common, useful dev commands.

Credits

This project is a fork of clean_ipynb by Kwat Medetgul-Ernar, with significant modifications and improvements. We gratefully acknowledge the original work that made this project possible.

Metadata

Release files for clean-py 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clean-py 1.0.0
File Size Uploaded
clean_py-1.0.0.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clean-py 1.0.0
File Interpreter ABI Platform
clean_py-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / clean_py-1.0.0.tar.gz

Download URL clean_py-1.0.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f79195a17a96f8a3229946572d0b6574ada929ca1211da82ba99a4c1c58cc861
BLAKE2b-256 checksum
How to use checksums
b38cf4951abb1bb2f99bff2448d7161d2bf300873bf3231a49cd38fb611fdbb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / clean_py-1.0.0-py3-none-any.whl

Download URL clean_py-1.0.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f81a548683ce7c09261abac5632b4b41c9f4b87a3cc56567f34e48563da1cf1
BLAKE2b-256 checksum
How to use checksums
a8c0ea8ad5cdca973bf0df9923a9997fbafdeba21439aabe58651dc5693e5b1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page