Skip to main content

A lightweight rule-based Python code formatter

Project description

CutyPy

CutyPy currently doesn't obey PEP 8 in many cases. It is a work in progress and may not be ready for production use. Use with caution and report any issues you encounter.

A lightweight Python code formatter.

Installation

pip install cutypy

About

CutyPy is a minimal and fast Python formatter designed to enforce consistent formatting rules across Python codebases.

Unlike large formatters that heavily restructure code, CutyPy focuses on deterministic formatting rules applied through a small rule engine. Each rule handles a specific formatting concern such as indentation, spacing, blank lines, or import ordering.

The formatter processes files using modular formatting rules, making the system easier to reason about, extend, and control.

Features

  • Deterministic Python formatting
  • Rule-based formatting system
  • Import sorting
  • Consistent indentation enforcement
  • Blank line normalization
  • Trailing space cleanup
  • Line ending normalization
  • Automatic EOF newline insertion
  • Optional check mode for CI pipelines

Usage

Format a file or directory:

cutypy path/to/file_or_directory

Check if files need formatting (useful for CI or pre-commit):

cutypy --check path/to/project

If formatting changes are required in check mode, CutyPy exits with a non-zero status code.

Formatting Rules

CutyPy applies a set of focused formatting rules:

  • Blank line normalization
  • Declaration spacing adjustments
  • Removal of excessive blank lines
  • End-of-file newline enforcement
  • Import ordering
  • Indentation consistency
  • Leading blank line cleanup
  • Line ending normalization
  • Trailing comma formatting
  • Removal of trailing spaces

Each rule operates independently, allowing the formatter to remain simple and predictable.

Project Structure

cutypy
├── __init__.py
├── fmt.py
├── format_file.py
└── rules
    └── format
        ├── blank_lines.py
        ├── declaration_spacing.py
        ├── double_blanks.py
        ├── eof_newline.py
        ├── import_sort.py
        ├── indentation.py
        ├── leading_blank_lines.py
        ├── line_endings.py
        ├── trailing_commas.py
        └── trailing_spaces.py
  • fmt.py provides the CLI entrypoint.
  • format_file.py handles formatting of individual files.
  • rules/format contains independent formatting rules applied sequentially.

Design Philosophy

CutyPy is built around a few core ideas:

  • Minimal implementation
  • Explicit formatting rules
  • Predictable output
  • Easy extensibility
  • Suitable for automation (CI / pre-commit)

Rather than trying to cover every stylistic decision, CutyPy focuses on enforcing a small set of reliable formatting guarantees.

Status

Experimental and under active development.

Links

Made by AttAditya

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

cutypy-0.1.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

cutypy-0.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file cutypy-0.1.1.tar.gz.

File metadata

  • Download URL: cutypy-0.1.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cutypy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 66f6c53268556768e11346a1326bcf54fe1faec1c2913fe74afb562b9fde5225
MD5 6b5a76d19f30c869f74e81f852227286
BLAKE2b-256 b600bb80c04512b95c0393ba726037b759db26da483fb765d8e829ed5dfd765c

See more details on using hashes here.

File details

Details for the file cutypy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cutypy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cutypy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92b75c7b33783be6136bda017ec324a1341395f7c980eed0599099ee52478cf3
MD5 4659a79b73c829cdac574524ab1b25cc
BLAKE2b-256 1004ce6ec41331790e7e43a67adda53aa79b1e5e7bbefe4a11de32965d376e1f

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