Skip to main content

ballpython

PyPI version Python Versions CI License: MIT

The zero-config Python code cleaner, syntax healer, and quality suite.

ballpython automatically repairs broken syntax, resolves missing imports, prunes dead code, scans for security vulnerabilities, and formats your code in a single command. Zero LLM dependencies, 100% offline, and fast.

Both ballpython and pycleaner CLI commands are identical.


Installation

pip install ballpython

Quickstart

1. Fix and format your code

Run ballpython on any file or directory. It automatically heals syntax errors, resolves missing imports, removes unused variables, and applies canonical formatting:

ballpython .

2. Check code in CI (Dry Run)

Check for syntax errors, security vulnerabilities, dead code, and linting violations without modifying any files on disk:

ballpython check .

What It Does Automatically

When you run ballpython, all engines run under the hood in one pass:

  • Syntax Healing: Repairs missing statement colons (def, class, if), accidental = assignments in conditionals, unclosed parentheses/brackets, tab/space mixups, and legacy Python 2 except/print statements.
  • Smart Import Resolution: Resolves undefined symbols to standard library modules and common aliases, inserts TYPE_CHECKING guards, and prunes unused imports.
  • Formatting & Modernization: Formats code to PEP 8 standards (powered by ruff), modernizes legacy type annotations (PEP 585/604), and removes redundant object inheritance.
  • Dead Code Pruning: Discovers and eliminates unreachable code, empty pass blocks, and unused private definitions.
  • Security & Taint Audit: Detects hardcoded API secrets, SQL/command injection patterns, and unsafe eval/exec/pickle calls.
  • Type Verification: Verifies function call signatures against bundled Typeshed stubs.

Pre-Commit Hook

Add ballpython to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/moonrox420/ball-python
    rev: v2.0.5
    hooks:
      - id: pycleaner
        args: ["check"]

Configuration

Optional configuration can be placed in pyproject.toml under [tool.pycleaner]:

[tool.pycleaner]
exclude = ["migrations/", "generated/"]
line-length = 88

License

MIT License.

Metadata

Release files for ballpython 2.1.2

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

Source distribution (sdist)

Source distribution for ballpython 2.1.2
File Size Uploaded
ballpython-2.1.2.tar.gz 137.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ballpython 2.1.2
File Interpreter ABI Platform
ballpython-2.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 260.5 kB

Release files / ballpython-2.1.2.tar.gz

Download URL ballpython-2.1.2.tar.gz
Size 137.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c61fe508d264d6053f150247bacccc8f52d07d11363d9995712609f1e65f618d
BLAKE2b-256 checksum
How to use checksums
536128bc0a266ca9cf55be748d5095904ad0f3d32b416825a25920321023d665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / ballpython-2.1.2-py3-none-any.whl

Download URL ballpython-2.1.2-py3-none-any.whl
Size 123.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88f76de49d4606dea81c6e15b0e0b1fc3dbef479ab6bd752cc9b124b46a05288
BLAKE2b-256 checksum
How to use checksums
cc7ead8599bd8187cd5f1f154df33c6959f9f18da6d495e5b0c66f6bba343232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.7

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.0

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