Skip to main content

CLI tool to clean, format and reorganize Python source files.

Project description

Moppy 🧹

A CLI tool that cleans and restructures Python source files.

What it does

Step Action
1 Remove # inline comments (--remove-comments)
2 Remove docstrings (--remove-docstrings)
3 Reorder code structure (--reorganize)
4 Auto-format with black, isort, autoflake

Code order after --reorganize

imports          →  import / from … import
variables        →  module-level constants and assignments
schemas/models   →  dataclasses, Pydantic BaseModel, TypedDict …
classes          →  regular class definitions
functions        →  def / async def
other            →  if __name__ == "__main__", bare expressions …

Install

pip install .

Or in editable / development mode:

pip install -e .

Usage

# Clean a single file (format only)
moppy myfile.py

# Remove comments
moppy myfile.py --remove-comments

# Remove comments + docstrings + reorder structure
moppy myfile.py --remove-comments --remove-docstrings --reorganize

# Clean an entire directory recursively
moppy ./src --reorganize

# Only current directory, no sub-folders
moppy ./src --no-recursive

# Preview changes without writing any files
moppy ./src --dry-run --reorganize

Options

Flag Description
--remove-comments Strip all # comments
--remove-docstrings Strip all docstrings
--reorganize Reorder top-level statements
--dry-run Show results without modifying files
--recursive / --no-recursive Recurse into sub-directories (default: on)

Dependencies

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

moppy_cli-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

moppy_cli-1.0.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file moppy_cli-1.0.0.tar.gz.

File metadata

  • Download URL: moppy_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for moppy_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b964dbb4c5fac02764bcd8820e00583b9109f3a3868c5436c909953a24cf187f
MD5 b61c46b30e1fcbfac82f7f45dd5cf21b
BLAKE2b-256 37a24357ebd7965c2984302111fdeb48efda1f0b8fb407fe8cc4bcbca8bc08ee

See more details on using hashes here.

File details

Details for the file moppy_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: moppy_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for moppy_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 983347809574134f8a86fd2f413097a156ba46d25970858cac41d77da839c125
MD5 3b9ae1310a426901152b1e083f299080
BLAKE2b-256 b94ec77f3b3a41db262de0a2cc685c5a10a819f66341db0fc79c09ff9e7c039b

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